(HDU)1570 -- A C

题目链接:https://vjudge.net/problem/HDU-1570

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <iostream>
 5 #include <algorithm>
 6 #include <string>
 7 #include <cstdlib>
 8 
 9 using namespace std;
10 
11 int f(int n)
12 {
13     if(n==0||n==1) return 1;
14     return n*f(n-1);
15 }
16 
17 int c(int m,int n)
18 {
19     return f(n)/(f(m)*f(n-m));
20 }
21 
22 int a(int m,int n)
23 {
24     return f(n)/f(n-m);
25 }
26 
27 int main()
28 {
29     int t,n,m;
30     char ch;
31     scanf("%d",&t);
32     while(t--)
33     {
34         getchar();
35         scanf("%c %d %d",&ch,&n,&m);
36         if(ch=='A') printf("%d\n",a(m,n));
37         if(ch=='C') printf("%d\n",c(m,n));
38     }
39 }

 

posted @ 2016-12-07 16:32  ACDoge  阅读(164)  评论(0编辑  收藏  举报