标签:
题目大意:
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<map> using namespace std; typedef unsigned long long LL; const int INF = 1e9+7; const int maxn = 105; const int MOD = 9973; LL dp[maxn][905]; void solve() { for(int i=0; i<=30; i++) dp[i][0] = 1; for(int i=1; i<=30; i++) for(int j=1; j<=i; j++) { dp[i][j] = dp[i-1][j] + (2*(i-j)+1) * dp[i-1][j-1]; if(j-2 >= 0) dp[i][j] += (i-j+1)*(i-j+1) * dp[i-1][j-2]; } } int main() { int T, n, k, cas = 1; solve(); scanf("%d", &T); while(T--) { scanf("%d %d", &n, &k); printf("Case %d: %llu\n",cas++, dp[n][k]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/chenchengxun/p/4899939.html