题目链接:http://acm.fzu.edu.cn/problem.php?pid=1036
解题思路:
数据太大,只能通过递推后找规律,求解。
递推做法:http://blog.csdn.net/dyangel2013/article/details/40790199
代码:
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int han[50005];
void hannuo()
{
han[0]=0;
han[1]=1;
int t=2;
int k=2;
int g=2;
cc: for(int i=1;i<=g;i++)
han[t++]=(han[t-1]+k)%10000;
k=k*2%10000;
g++;
if(t<50004)
goto cc;
}
int main()
{
int n;
hannuo();
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",han[n]);
}
}