dp 累加
#include<iostream>
#include<queue>
#include<utility>
using namespace std;
#define pii pair<int,int>
int main(){
int n, dp[14][14];
queue<pii> q;
pii test;
int i, j;
while(cin >> n){
for( i=0;i<n;i++){
cin >> test.first >> test.second;
q.push(test);
}
}
for(i=1;i<14;i++){
for(j=1;j<=i;j++){
if(j==1 || j==i){
dp[i][j]=1;
}
else{
dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
}
}
}
do{
test=q.front();
cout << dp[test.first][test.second]<<'\n';
q.pop();
}while(!q.empty());
return 0;
}
啊!!!
Green Judge不能用 <bits/stdc++.h> 函式庫要自己查,好煩