http://poj.org/problem?id=2551
题意:
给出一个数,求能被由1组成的数整除的最少位数。
思路:
1 #include<iostream> 2 #include<string> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 7 8 int main() 9 { 10 //freopen("D:\txt.txt", "r", stdin); 11 int n; 12 while (cin >> n) 13 { 14 int m = 1; 15 int ans = 1; 16 m = m%n; 17 while (m) 18 { 19 m = (m * 10 + 1) % n; 20 ans++; 21 } 22 cout << ans << endl; 23 } 24 }