HDU 2154ダンスカーペット
2872 ワード
http://acm.hdu.edu.cn/showproblem.php?pid=2154
つまらない問題...
View Code
つまらない問題...
View Code
#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
",a[n]%mod);
}
return 0;
}