求1/i的循环节长度的最大值
#include <iostream>
#include<cstring>
using namespace std;
const int MAXN=1005;
int res[MAXN];
int main()
{
memset(res, 0, sizeof res);
int i,j,n;
for(int temp=1;temp<=1000;temp++){
i=temp;
while(!i%2) i>>=1; //一个小小的优化
while(!i%5) i/=5;
n=1;
for(j=1;j<=1000;j++){
n*=10;
n%=i;
if(n==1){
res[temp]=j;
break;
}
}
}
int max_re;
while (cin >> n) {
max_re = 1;
for (i = 1; i <= n; i++) {
if (res[i] > res[max_re]) {
max_re = i; }
}
cout << max_re << endl;}
return 0;
}