http://acm.hdu.edu.cn/showproblem.php?pid=2154
无聊题。。。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <stdio.h> #include <stdlib.h> #include <string.h> const int mod=10000; int a[1001],b[1001],c[1001]; int main() { int n; while(scanf("%d",&n),n) { a[0]=1;b[0]=c[0]=0; for(int i=1;i<=n;i++) { a[i]=(b[i-1]+c[i-1])%mod; b[i]=(a[i-1]+c[i-1])%mod; c[i]=(a[i-1]+b[i-1])%mod; } printf("%d\n",a[n]%mod); } return 0; }