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 ...
随机推荐
- MVC ViewModel
ViewModel这个概念不只是在在MVC模式中有,你会在很多关于MVC.MVP.MVVM的文章中见到这个说法,并且这个概念在任何技术中都有可能提到,比如ASP.NET, Silverlight, W ...
- NSDictionary
// ------------------------------字典------------------------------------------------- NSDictionary *d ...
- Java基础之集合框架——使用HashMap地图(TryPhoneBook1)
控制台程序. 首先改进Peron类,使Person可以在地图中用作键,进而存储电话簿中的项.必须添加equals()方法并重写默认的hashCode()方法. import java.io.*; pu ...
- "淘宝推荐系统简介"分享总结
概述: 此分享是关于淘宝推荐系统简介 1.推荐引擎就是:如何找到用户感兴趣的东西和以什么形式告诉用户:2.推荐引擎的作用:提高用户忠诚度,提高成交转化率和提高网站交叉销售能力:3.推荐系统核心:产品, ...
- 实验十三_编写、应用中断例程_2 & 总结
编写并安装int 7ch中断例程,功能为完成loop指令的功能 参数:(cx)= 循环次数,(bx)= 位移 以上中断例程安装成功后,对下面的程序进行单步跟踪,尤其注意观察int.iret指令执行前后 ...
- MAX(A,B)
MAX(A,B) 可以把x,或者y的变量扔进去比较,会自动放出比较结果,这样就避免的三目运算.
- IIS7.5解决应用程序池回收假死问题
使用windows server 2008 r2解决回收假死的问题. 具体做法是: 打开应用程序池 -> 高级设置 ->在“禁止重叠回收”里选择“true”,这样就有效避免了应用程序池回收 ...
- paper 2:图像处理常用的Matlab函数汇总
一 图像的读写 1 imread imread函数用于读入各种图像文件,如:a=imread('e:\w01.tif') 注:计算机E盘上要有w01相应的.tif文件. 2 imwrite imwri ...
- ie6双边距解决
这个bug是ie6有名的双边距bug:同时为一个元素设置向一个方向偏移和对这个方向进行外边距设置,比如float:left,margin-left:45px;在其他浏览器下是显示正常的,在ie6下这个 ...
- Jquery文档接口遍历
// children():获取所有子元素 <%@ page language="java" contentType="text/html; charset=utf ...