POJ 2551 (同余问题)

View Code
 1 /*
2 注意:
3 111111 的余数是 111110的余数 +1
4 以此类推
5 */
6
7 #include<stdio.h>
8
9 int main()
10 {
11 int n;
12 while(EOF != scanf("%d",&n))
13 {
14 int t = 1%n;
15 int num = 1;
16 while(t)
17 {
18 t = t*10 +1;
19 num++;
20 t%=n;
21 }
22 printf("%d\n",num);
23 }
24 return 0;
25 }

 

posted @ 2012-04-03 14:53  知行执行  阅读(369)  评论(0编辑  收藏  举报