hdoj--2522--A simple problem(数学模拟)
A simple problem
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3866 Accepted Submission(s): 1444
4
2
3
7
168
0.5
0.3
0.142857
0.005952380
/*其实这一道题跟一般的数学除法很像,只是真正的小数除法都是在小数点后边,
但是那样在c语言中是行不通的,所以每一步乘以10来计算,vis标记是否出现过*/
#include<stdio.h>
#include<string.h>
#define 100000+100
int vis[MAX];
int main()
{
int yu,t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(n==1)
{
printf("1\n");
continue;
}
if(n<0)
{
printf("-");
n=-n;
}
printf("0.");
memset(vis,0,sizeof(vis));
yu=1,vis[1]=1;
while(yu)
{
yu*=10;
printf("%d",yu/10);
yu%=10;
if(vis[yu])
break;
vis[yu]=1;
}
printf("\n");
}
return 0;
}
hdoj--2522--A simple problem(数学模拟)的更多相关文章
- HDOJ 4267 A Simple Problem with Integers (线段树)
题目: Problem Description Let A1, A2, ... , AN be N elements. You need to deal with two kinds of opera ...
- HDU 2522 A simple problem (模拟)
题目链接 Problem Description Zty很痴迷数学问题..一天,yifenfei出了个数学题想难倒他,让他回答1 / n.但Zty却回答不了^_^. 请大家编程帮助他. Input 第 ...
- HDU 2522 A simple problem( 分数循环节 )
链接:Here! 思路:模拟除法,当余数再次出现的时候一定是遇到了循环节( 可看下图例子 ),否则的话继续除法的步骤,直到被除数为 0 . 注意:这道题不需要重新申请一个数组来单独存放答案,如果符合要 ...
- mutiset HDOJ 5349 MZL's simple problem
题目传送门 /* 这题可以用stl的mutiset容器方便求解,我对这东西不熟悉,TLE了几次,最后用读入外挂水过. 题解有O(n)的做法,还以为我是侥幸过的,后来才知道iterator it写在循环 ...
- HDU-2522 A simple problem
http://acm.hdu.edu.cn/showproblem.php?pid=2522 学习://除数的运算的应用和算法.除法的本质,如果余数出现重复就表示有循环节 A simple probl ...
- 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 ...
- poj 3468:A Simple Problem with Integers(线段树,区间修改求和)
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 58269 ...
- ACM: A Simple Problem with Integers 解题报告-线段树
A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...
随机推荐
- LVS十种调度算法介绍
1.轮叫调度(Round Robin)(简称rr) 轮叫调度(Round Robin Scheduling)算法就是以轮叫的方式依次将请求调度不同的服务器,即每次调度执行i = (i + 1) mod ...
- C#泛型类的用途和说明
class Program { public class Test<T, S> { //泛型类的类型参数可用于类成员 ...
- 错误信息:getOutputStream() has already been called for this response
原因(转): getOutputStream()和getWriter()这两个方法不能在一个请求内同时使用, 如果使用forward,这时将要跳转到的页面是要用getWriter()方法获得输出流把页 ...
- [Offer收割]编程练习赛36
逃离单身节 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector&g ...
- Windows Phone - 按钮/button 控件
System.Windows.Controls.Button button控件一.button控件的各种样式的展示可以通过 …… 来给控件定义公共的样式调用样式的方法:在Button控件上添加样式 ...
- 4.4.2 OpenGL几何变换编程实例
程序运行结果如下图: #include <GL/glut.h> #include <stdlib.h> #include <math.h> /* 初始化显示窗口大小 ...
- CSS读书笔记(1)---选择器和两列布局
(1)CSS选择器优先权选择. 优先权从大到小的选择如下: 标有!important关键字声明的属性 HTML中的CSS样式属性 <div style="color:red" ...
- C#学习 第九节
构造器 1.构造器(constructor)是类型的成员之一: 2.狭义的构造器是指“实例构造器”(instance constructor): 3.构造器的调用 student stu =new s ...
- 前端开发—CSS
CSS 基础概念 致命三问: 它是什么? 层叠样式表,主要作用是对html标签进行装饰. 它的作用:再 html 框架的基础上 ,对标签内容做美化工作. 注释方法:/*单行注释*/ 多行注释同理与h ...
- NGUI报错处理
Unity5.4.1与NGUI出现的问题Ignoring menu item NGUI because it is in no submenu! Ignoring menu item NGUI ...