标签:dp
#include <cstdio> #include <iostream> using namespace std; const int maxn = 1000000; #define INF 1000000007L long long int dp[maxn+10]; void fun(){ dp[0] = 1; dp[1] = 1; for(long long i = 2; i <= maxn;i++){ dp[i] = (dp[i-1] + ((long long)(i-1)) % INF * dp[i-2]) % INF; } } int main(){ int t; fun(); scanf("%d",&t); int q = 1; while(t--){ int a; scanf("%d",&a); printf("Case #%d:\n",q++); printf("%I64d\n",dp[a]); } return 0; }
标签:dp
原文地址:http://blog.csdn.net/qq_24667639/article/details/45938057