POJ-2551
来源:互联网 发布:sql 分页查询 编辑:程序博客网 时间:2024/04/28 22:40
本题大意:给出一个数字n,至少要多少个连续的1(写成十进制)能整除n
#include "stdio.h"#include "stdlib.h"int main(){int n;while(scanf("%d",&n)!=EOF){if(n==1){printf("1\n");continue;}else{int i=1;int sum=1;while(sum){sum=(sum*10+1)%n;i++;}printf("%d\n",i);}}//system("pause");return 0;}
注:
1. 之前在while的时候scanf没有判断不等于EOF,所以导致超时
2. 之前在计算sum的时候没有进行取模,导致sum会是一个非常大的数,int类型存不下,long也存不下,所以进行取模运算
0 0
- POJ-2551
- POJ 2551 Ones
- POJ 2551 Ones
- POJ 2551 ONES
- POJ 2551 ONES
- poj 2551 Ones
- poj 2551 Ones
- POJ 2551 ones
- poj 2551 Ones
- poj 2551 除法
- POJ 2551 Ones
- POJ - 2551 Ones
- POJ 2551 Dungeon Master
- POJ 2551 Ones
- POJ 2551 Dungeon Master
- POJ
- poj
- POJ
- LeetCode OJ - Binary Tree Postorder Traversal
- C语言优化实例:循环中减少判断
- Class02 图像混合Blending
- 华为OJ IP地址判断有效性
- C语言 如何获取文件名称 system dir
- POJ-2551
- CodeForces 349 C. Mafia
- Class03 改变图像对比度和亮度
- Class04 添加滑动条
- 小公司经营
- Nginx进程模型(二)worker进程
- The Great Gatsby
- CentOS6.5安装配置SVN
- Java中接口定义成员变量