HDU 2154 跳舞毯

http://acm.hdu.edu.cn/showproblem.php?pid=2154

无聊题。。。

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\n",a[n]%mod);

    }

    return 0;

}

 

你可能感兴趣的:(HDU)