博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2551 Ones
阅读量:7117 次
发布时间:2019-06-28

本文共 860 字,大约阅读时间需要 2 分钟。

OnesTime Limit: 1000MS Memory Limit: 65536K

Total Submissions: 10306 Accepted: 5869
Description
Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n?
Input
Each line contains a number n.
Output
Output the number of digits.
Sample Input
3
7
9901
Sample Output
3
6
12
Source
Waterloo local 2001.06.02

//136K    16MS    C++    273B//题意:求最少个连续的1 mod n为0    //思路:设i个1 %n 余数为 e,i+1个1 为(e*10+1)%n //      当e为0时得到最少个1的数量 #include
int main(void){ int n; while(scanf("%d",&n)!=EOF) { int e=1; int cnt=1; while(e!=0){ e=10*e+1; e%=n; cnt++; } printf("%d\n",cnt); } return 0;}

 

转载于:https://www.cnblogs.com/GO-NO-1/articles/3330891.html

你可能感兴趣的文章
如何来看单片机外设A/D转换器ADC0804时序图
查看>>
NetApp发布云计算计划及新操作系统
查看>>
IPHONE 6S电池保护壳丑?漂亮的都有专利了
查看>>
云计算和社交网络将推动美科技业重组
查看>>
浙江乌镇已布500多个人脸识别摄像头;宁波、嘉兴将引入中考英语人机对话考试技术,用机器为考生口语评分...
查看>>
15分钟学会使用Git和远程代码库
查看>>
《OpenStack实战》——1.3 关联OpenStack及其控制的计算资源
查看>>
《C++面向对象高效编程(第2版)》——1.15 小结
查看>>
人工智能悖论:简单的动作比复杂的推理更难以实现
查看>>
《C++游戏编程入门(第4版)》——2.9 使用逻辑运算符
查看>>
PostgreSQL修炼之道:从小工到专家. 2.1 从发行版本安装
查看>>
《Unity 5.x游戏开发实战》一1.2 从头开始——Unity中的项目
查看>>
深入实践Spring Boot1.4.1 在IDEA环境中运行
查看>>
《CUDA高性能并行计算》----1.2 运行我们自己的串行程序
查看>>
《HBase实战》一2.9 小结
查看>>
细说分布式数据库的过去、现在与未来
查看>>
在Linux中使用LVM构建灵活的磁盘存储(第一部分)
查看>>
《21天学通C++(第7版)》——17.1 std::vector的特点
查看>>
《HTML5完美游戏开发》——第1章 Open Web Game王国
查看>>
JDBC案例演示,供参考
查看>>