Problem Description
Are you excited when you see the title "AC" ? If the answer is YES , AC it ;

You must learn these two combination formulas in
the school . If you have forgotten it , see the picture.

Now I will give you n and m ,
and your task is to calculate the answer .

 
Input
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)
 
Output
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.
 
Sample Input
2
A 10 10
C 4 2
 
Sample Output
3628800
6
 
 #include <stdio.h>

 int jieCheng(int number);

 int main(){
int T;
char c;
int n;
int m;
int n_jieCheng;
int m_jieCheng;
int n_m_jieCheng;
int result; scanf("%d",&T); while(T--){
getchar(); scanf("%c%d%d",&c,&n,&m); n_jieCheng=jieCheng(n);
m_jieCheng=jieCheng(m);
n_m_jieCheng=jieCheng(n-m); if(c=='A')
result=n_jieCheng/n_m_jieCheng; else
result=n_jieCheng/(m_jieCheng*n_m_jieCheng); printf("%d\n",result);
}
return ;
} int jieCheng(int number){
int result;
int i; result=; for(i=;i<=number;i++)
result*=i; return result;
}
 

随机推荐

  1. 两年内从零到每月十亿 PV 的发展来谈 Pinterest 的架构设计(转)

    原文:Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years 译文:两年内从零到每月十亿 PV ...

  2. 关于VSS配置遇到的问题及解决方法

    今天安装网上的教程开始部署源代码管理器 相关工具 VSS安装包:http://url.cn/PolkN8 VSS汉化包:http://url.cn/PeHq1A 具体安装教程请参考:http://ww ...

  3. UVALive 7079 - How Many Maos Does the Guanxi Worth(最短路Floyd)

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  4. nyoj 119 士兵杀敌(三)(RMQ)

    士兵杀敌(三) 时间限制:2000 ms  |  内存限制:65535 KB 难度:5   描述 南将军统率着N个士兵,士兵分别编号为1~N,南将军经常爱拿某一段编号内杀敌数最高的人与杀敌数最低的人进 ...

  5. 第三次作业之Calculator项目随笔

    附:Github的链接:https://github.com/mingyueanyao/object-oriented/tree/master/Calculator 1.初见题目: 第一眼看到题目最大 ...

  6. Codeforces 479E. Riding in a Lift (dp + 前缀和优化)

    题目链接:http://codeforces.com/contest/479/problem/E 题意:         给定一个启示的楼层a,有一个不能去的楼层b,对于你可以去的下一个楼层必须满足你 ...

  7. javaScript中"=="和"==="运算符的区别

    相同点: 两个运算符均可用于比较两个值是否相等,可允许操作任意类型的操作数,如果操作数相等则返回true,否则返回false. 不同点: "==="运算符也称为严格相等运算符,它用 ...

  8. 在WPF程序中使用摄像头兼谈如何使用AForge.NET控件(转)

    前言: AForge.NET 是用C#写的一个关于计算机视觉和人工智能领域的框架,它包括图像处理.神经网络.遗传算法和机器学习等.在C#程序中使用摄像头,我习惯性使用AForge.NET提供的类库.本 ...

  9. CodeForces 163B Lemmings 二分

    Lemmings 题目连接: http://codeforces.com/contest/163/problem/B Descriptionww.co As you know, lemmings li ...

  10. Codeforces Gym 100015C City Driving 离线LCA

    City Driving 题目连接: http://codeforces.com/gym/100015/attachments Description You recently started fre ...