标签:递推
代码:
#include<cstdio> #include<cstring> #define N 1000 #define mod 1000000007 using namespace std; long long dp[N+5]; int main() { dp[1]=2; dp[2]=3; for(int i=3;i<=N;i++) { dp[i]=(dp[i-1]%mod+dp[i-2]%mod)%mod; } int k=0; int n; while(scanf("%d",&n)==1) { printf("Case #%d: %lld\n",++k,dp[n]); } return 0; }
标签:递推
原文地址:http://blog.csdn.net/xky1306102chenhong/article/details/46404609