http://acm.hdu.edu.cn/showproblem.php?pid=6114
【思路】
就是求C(m,n)
【板】
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; const int maxn=1e3+2; int n,m; ll C[maxn][maxn]; const ll mod=1e9+7; void init() { C[0][0]=1; for (int i=0;i<maxn;i++) { C[i][0]=1; for (int j=1;j<=i;j++) { C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod; } } } int main() { init(); int T; scanf("%d",&T); while(T--) { scanf("%d%d",&n,&m); if(n>m) swap(n,m); ll ans=C[m][n]; cout<<ans<<endl; } return 0; }