【数论,水题】UVa 10127 - Ones
2015-03-21 11:11
253 查看
题意:给你一个数n,问最少有多少个1构成的“1”串(1,11,...)能整除n;
比如:111能被3整除; 111111能被7整除;...
作为水货觉得只要自己能1A的都是水题=。 =
#include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> using namespace std; const int maxn = 10010; int main() { int n, p[maxn]; while(~scanf("%d", &n)) { if(!n) {printf("0\n"); continue;} int len = log10(n)+1; int val = 0, x; for(x = 0; x < len; x++) { val = val*10 + 1; } int res = 0; if(val/n == 0) { val = val*10+1; x++; } res = val%n; while(res) { res = res*10+1; res = res%n; x++; } printf("%d\n", x); } return 0; }View Code
相关文章推荐
- UVA-10127 Ones (数论)
- UVA 10127 Ones (数论) 计算至少要多少位十进制的1能够被n整除
- UVA 10127 - Ones(数论)
- UVA 10127 - Ones(数论)
- uva 10127 - Ones(数论)
- uva 10127 - Ones(数论)
- Uva 数论&&计算几何 几个水题
- UVa:10127 Ones
- UVa 10127 - Ones
- UVa 10127/POJ 2551 Ones (模运算&转换思想)
- uva 10127 - Ones
- uva 10127——ones
- UVA - 10127 Ones
- 【数论,水题】UVa 11728 - Alternate Task
- uva 10127 Ones
- UVa Problem 10127 Ones (仅由 1 组成的数)
- UVa Problem Solution: 10127 - Ones
- uva 10290 {Sum+=i++} to Reach N (数论-整数和素数)
- UVA 11461 - Square Numbers(水题)
- UVALive 7337 Counting Weekend Days【水题】