POJ 2551
1 #include<iostream> 2 #include<stdio.h> 3 #include<string> 4 using namespace std; 5 6 //int my_pow(int ,int ); 7 int main() 8 { 9 //freopen("acm.acm","r",stdin); 10 int s; 11 int i; 12 int num; 13 while(cin>>s) 14 { 15 num = 0; 16 for(i = 0; ; ++ i) 17 { 18 num = num*10 + 1; 19 if(num % s == 0) 20 { 21 cout<<i+1<<endl; 22 break; 23 } 24 else 25 { 26 num %= s; 27 } 28 } 29 //cout<<num<<endl; 30 31 32 } 33 } 34 /*int my_pow(int a,int b) 35 { 36 if(b == 0) 37 return 1; 38 else 39 { 40 return a*my_pow(a,b - 1); 41 } 42 }*/