【组合数学】Pole Arrangement, ACM/ICPC Daejeon 2012, UVa1638

来源:互联网 发布:sql server使用教程 编辑:程序博客网 时间:2024/05/16 06:49
#include<bits/stdc++.h>using namespace std;int T,n,l,r;typedef long long LL;LL dp[25][25][25];void init(){dp[1][1][1] = 1;for(int i=2;i<=20;i++)for(int j=1;j<=20;j++)for(int k=1;j+k-1<=i;k++)dp[i][j][k] = dp[i-1][j-1][k]+dp[i-1][j][k-1]+dp[i-1][j][k]*(i-2);}int main(){ios::sync_with_stdio(false);init();cin>>T;while(T--){cin>>n>>l>>r;cout<<dp[n][l][r]<<endl;}return 0;}

0 0
原创粉丝点击