描述
Do you know 2011-11-11 is “Singlehood Festival”,
and there is a kind of number which named “Singlehood Number”. “Singlehood Number” is a number which in decimal notation is a sequence of 1‘s.
Now given any integer 0 <= n <= 10000 not divisible by 2 or 5, find out a “Singlehood Number” which can be divided exactly by n. How many digits are in the smallest “Singlehood Number”?
输入
Each line contains a number n.
输出
For each n output the number of digits.
样例输入
3
7
样例输出
3
6
#include <stdio.h> #include <string.h> #include <algorithm> #include <queue> using namespace std; int main() { int n; while(~scanf("%d",&n)) { int cnt = 1,s = 1; while(s%n!=0) { s%=n; s = s*10+1; cnt++; } printf("%d\n",cnt); } }
TZU2014年省赛个人热身赛1 3741:Singlehood Number,布布扣,bubuko.com
TZU2014年省赛个人热身赛1 3741:Singlehood Number
原文:http://blog.csdn.net/libin56842/article/details/22533575