题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12869
解题报告:看到n的范围这么大,一看就是找规律,把前30个打出来之后就找到了循环节,循环节从第25个开始,长度为6。离线打表,把所有结果都打出来了。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int ans1[] = {,
,,,,,,,,,,,,,,,,,,,,,,,};
int ans2[] = {,,,,,};
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n <= )
printf("%d\n",ans1[n]);
else printf("%d\n",ans2[(n - ) % ]);
}
/* int n,que[30];
while(scanf("%d",&n)!=EOF)
{
int temp = 1;
for(int i = 1;i <= n;++i)
{
printf("%d,",temp);
temp *= 2;
int f = 0;
while(temp)
{
que[f++] = temp % 10;
temp /= 10;
}
sort(que,que+f);
for(int j = 0;j < f;++j)
temp = 10 * temp + que[j];
}
}
return 0;*/
}