In the first line , there is a integer T indicates the number of test cases.
Then T cases follows in the T lines.
Each case contains a character 'A' or 'C', two integers represent n and m. (1<=n,m<=10)
输出
For each case , if the character is 'A' , calculate A(m,n),and if the character is 'C' , calculate C(m,n).
And print the answer in a single line.
样例输入 Copy
2
A 10 10
C 4 2
样例输出 Copy
3628800
6
#include
#include
using namespace std;
int C1(int n, int m)
{
int a = 1, b = 1;
for (int i = n; i > n - m; --i) a *= i;
for (int i = m; i >= 1; i--) b *= i;
return a/b;
}
int A1(int n, int m){
int a = 1;
for (int i = n; i > n - m; --i) a *= i;
return a;
}
int main()
{
int n,m,num;
cin>>num;
string op;
const string A;
for(int j=0;j<num;j++)
cin >>op >>n >>m;
for(int i=0;i<num;i++)
{if(op==A)
cout<<A1(n,m)<<endl;
else
cout<<C1(n,m)<<endl;}
}