XDU 1109
#include<stdio.h> #define N 10007 #define maxn 1000005 int dp[maxn]; int main() { dp[1]=1,dp[2]=2,dp[3]=4; for(int i=4;i<maxn;i++) dp[i]=dp[i-1]%N+dp[i-2]%N+dp[i-3]%N; int n; while(scanf("%d",&n)!=EOF) printf("%d\n",dp[n]%N); }
#include<stdio.h> #define N 10007 #define maxn 1000005 int dp[maxn]; int main() { dp[1]=1,dp[2]=2,dp[3]=4; for(int i=4;i<maxn;i++) dp[i]=dp[i-1]%N+dp[i-2]%N+dp[i-3]%N; int n; while(scanf("%d",&n)!=EOF) printf("%d\n",dp[n]%N); }