ACM题目————A simple problem
Description
Input
Output
Sample Input
Sample Output
和我名字那么相近的题目,当然要AC了!
//如果余数出现重复就表示有循环节
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <deque>
#include <string>
#include <string.h>
#include <vector>
#include <stack>
#include <ctype.h>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <time.h>
#include <bitset>
#include <list> using namespace std; int f[100000];
int flag[100000];
int main()
{
int t,m,y,cnt,n,i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(n<0) //如果是负数
{
printf("-");//首先打印负号
n*=-1;//取反后当做正数处理
}
if(n==1)
{
printf("1\n");
continue;
}
y=1;
cnt=0;
memset(flag,0,sizeof(flag));//初始化为0
flag[1]=1;
while(y)
{
y*=10;
f[cnt++]=y/n;
y%=n;
if(flag[y])//如果使用过,说明出现循环数节
break;
flag[y]=1;//记录余数是否使用过
}
printf("0.");
for(i=0; i<cnt; i++)
printf("%d",f[i]);
printf("\n");
}
return 0;
}
ACM题目————A simple problem的更多相关文章
- ACM题目————The Blocks Problem
代码参考:http://www.hankcs.com/program/uva-q101-the-blocks-problem.html Description Background Many area ...
- ACM: A Simple Problem with Integers 解题报告-线段树
A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...
- [ACM] poj 3468 A Simple Problem with Integers(段树,为段更新,懒惰的标志)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 55273 ...
- hdu 5349 MZL's simple problem
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5349 MZL's simple problem Description A simple proble ...
- hdu_3483A Very Simple Problem(C(m,n)+快速幂矩阵)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3483 A Very Simple Problem Time Limit: 4000/2000 MS ( ...
- 2018 ACMICPC上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节) 链接:https://ac.nowcoder.co ...
- A - 敌兵布阵 ——B - I Hate It——C - A Simple Problem with Integers(线段树)
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况.由于 ...
- POJ 3468 A Simple Problem with Integers(线段树 成段增减+区间求和)
A Simple Problem with Integers [题目链接]A Simple Problem with Integers [题目类型]线段树 成段增减+区间求和 &题解: 线段树 ...
- POJ 3468 A Simple Problem with Integers(线段树/区间更新)
题目链接: 传送门 A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Description Yo ...
随机推荐
- iOS 归档
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...
- json在action,$.ajax{}中的使用
首先需导入包:ezmorph-1.0.4.jar Action中的调用的方法: public void getObject(){ try { if(cname!=null&& ! ...
- PAT 解题报告 1003. Emergency (25)
1003. Emergency (25) As an emergency rescue team leader of a city, you are given a special map of yo ...
- Azure billing 分析(2)
美国中南部的2008R2的A1的VM放了一天,CPU时间涨了13个小时,有点小贵,真的没有操作啊... 提示早上7到9点有一个小高峰. 看来平时没什么访问量时,还是改成A0能省点钱.因为第一天是用A0 ...
- Winform TreeView 节点拖动
private void treeView_ItemDrag(object sender, ItemDragEventArgs e) { TreeNode dragNode = e.Item as T ...
- Java基础(32):String与StringBuilder、StringBuffer的区别(String类)
在Java中,除了可以使用 String 类来存储字符串,还可以使用 StringBuilder 类或 StringBuffer 类存储字符串,那么它们之间有什么区别呢? String 类具有是不可变 ...
- .net 反编译工具
遇到一个需求,做一个专门访问自己网站的浏览器给用户使用,这个浏览器提供登录功能.此时是一个安装在客户端的exe程序,做登录验证要用到webservice,不能将验证逻辑写入exe中,否则客户端可以利用 ...
- Cookie—的使用
编写 Cookie 浏览器负责管理用户系统上的 Cookie.Cookie 通过 HttpResponse 对象发送到浏览器,该对象公开称为 Cookies 的集合. 可以将 HttpResponse ...
- Android -- 自定义View(一)
1,引言:刚从国庆长假的放荡中醒过来,已经有将近十天没碰电脑了,上午写写代码感觉手还是挺生的,想把自定义view好好的系统的学学,在网上看了看别人出的教程 ,stay4it的自定义view感觉还是挺好 ...
- 解决maven编译spark1.5报错问题
spark1.5发布了,赶紧去下了源码尝鲜 git clone git://github.com/apache/spark.git -b branch-1.5 输入命令进行编译 ./make-dist ...