ZOJ 1889 题解利用公式很快就解出来了
1 #include<stdio.h>
2
3 int main()
4 {
5 int k, n;
6 long long num;
7
8 while(scanf("%d", &n) != EOF)
9 {
10 k = 1;
11 num = 1;
12 while(num%n != 0)
13 {
14 num = (num*10+1)%n; //一开始把n忘了写超时了,最后改了一下
15 k++;
16 }
17 printf("%d\n",k);
18 }
19 return 0;
20 }