A C
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4206 Accepted Submission (s): 2671
Problem Descriptionare You excited the title "AC"? If The answer is YES, AC it;
You must learn these and combination formulas in the school. If you had forgotten it, see the picture.
Now I'll give you N and M, and your task was to calculate the answer.
Inputin the first line, there is a integer T indicates the number of the test cases.
Then T-cases follows in the T lines.
Each case contains a character ' a ' or ' C ', the integers represent N and M. (1<=n,m<=10)
Outputfor each case, if the character are ' a ', calculate a (m,n), and if the character is ' C ', calculate C (m,n).
and print the answer in a.
Sample Input
2 a 10C 4 2
Sample Output
36288006
Authorlinle
Sourcehdu 2007-1 Programming Contest Harbin Life is also drunk, put a fake bored to brush this problem play.
#include <iostream>using namespace std;int fac (int k) {int sum=1;for (int i=1;i<=k;i++) Sum*=i;return sum;} int main () {int N,n,m;char ch;cin>>n;while (n--) {cin>>ch>>n>>m;if (ch== ' A ') COUT<<FAC (n )/(FAC (N-M)) <<endl;else if (ch== ' C ') COUT<<FAC (N)/(FAC (M) *FAC (n-m)) <<endl;} return 0;}
Hangzhou Electric HDU 1570 A C