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. c++builder 重载WindowProc、WndProc 截获消息

    c++builder 重载WindowProc.WndProc 截获消息 方法一WindowProc void __fastcall  myWindowProc(Messages::TMessage ...

  2. 转】MyEclipse使用总结——MyEclipse去除网上复制下来的来代码带有的行号

    原博文出自于: http://www.cnblogs.com/xdp-gacl/p/3544208.html 感谢! 一.正则表达式去除代码行号 作为开发人员,我们经常从网上复制一些代码,有些时候复制 ...

  3. HTML5每日一练之progress标签的应用

    progress标签:从名字上来看,估计大家也能猜到这个标签是什么标签了,没错,他是一个进度条.在HTML5中我们终于可以不用模拟了. <progress id="W3Cfuns_pr ...

  4. tomcat 粗略笔记

    GlobalNamingResources 存在于server.xml中,定义全局公共数据源,如果host中有大量引用相同的数据源,那么可以都配在这里 <GlobalNamingResource ...

  5. JavaScript面向对象简介

    JavaScript面向对象简介 @(编程) [TOC] 1. 命名空间 命名空间是一个容器,它允许开发人员在一个独特的,特定于应用程序的名称下捆绑所有的功能. 在JavaScript中,命名空间只是 ...

  6. JPA多对多@manytomany注解配置实例

    维护端注解 @ManyToMany (cascade = CascadeType.REFRESH) @JoinTable (//关联表 name = "student_teacher&quo ...

  7. 使用timer8秒读取一次方法进行操作

    public void TestofTimer() { System.Timers.Timer tt = new System.Timers.Timer(); //获取或设置引发 Elapsed 事件 ...

  8. 【Cocos2d-X开发学习笔记】第18期:动作类之改变动作对象、函数回调动作以及过程动作的使用

    本系列学习教程使用的是cocos2d-x-2.1.4(最新版为3.0alpha0-pre) ,PC开发环境Windows7,C++开发环境VS2010 一.改变动作执行对象 CCTargetedAct ...

  9. POJ 2828Buy Tickets

    POJ 2828 题目大意是说有n个插入操作,每次把B插入到位置A,原来A以后的全部往后移动1,球最后的序列 tree里保存的应该是这整个区间还有多扫个位置可以插入数据,那么线段树里从后往前扫描依次插 ...

  10. HDU2897邂逅明下(博弈)

    题目是说每次每个人可以取[p,q],而且是最后一个不得不取完的人输 这道题刚刚看别人过,还一直纠结感觉不会做,然后想到1+q的倍数,还是不会,想到p+q的倍数,却发现最后一个取的人是输的,然后就更加无 ...