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. pyQt 每日一练习 -- 登录框

    #coding=utf-8 #第一个练习,登录框 import sys from PyQt4 import QtGui,QtCore #登录框 class LoginBox(QtGui.QWidget ...

  2. Microsoft Office Excel 不能访问文件“XXXXXXXXXXXXX.xls”。 可能的原因有:

    解决办法:1. 1).通过webconfig中增加模拟,加入管理员权限, <identity impersonate="true" userName="系统管理员& ...

  3. vim之grep

    [vim之grep] :vimgrep 用于多文件搜索,如 1):vim[grep] start_stage *   在当前目录下(不包括子目录)搜索 2)  :vim[grep] start_sta ...

  4. 您的IP不在有效范围 ip:port为 [10.15.22.15]

  5. System.Data.SqlTypes.SqlNullValueException: 数据为空。不能对空值调用此方法或

    有可能读出的数据为NULL,可以这样改: 方法一:while (reader.Read()){ for (int i = 0; i < 7; i++) { if (reader.IsDBNull ...

  6. js判断滚动方向

     //页面滚动监听事件     window.onscroll = function (e) {                scrollFunc();         $("#t&quo ...

  7. jquery自定义方法

    总结: * jQuery中添加自定义或函数方法1,如 $.fn.extend({'aa':function(){}}) 或 jQuery.fn.aa=function(){}, 这种调用时就得这样,$ ...

  8. AS与JS相互通信(Flex中调用js函数)

    转载自http://www.blogjava.net/Alpha/archive/2009/06/27/284373.html Flex中As调用Js的方法是:     1.导入包 (import f ...

  9. JAVA组程序优化综合考试试题

    题目原型: 有一张标准的树状结构表,里面有Structure_Id和 Parent_Id两个关键列,记录了结点的父子关系.现在要求添加一个字段为 Structure_Code ,标记为 三位一个节点关 ...

  10. 【转】larbin主要代码说明

    转自:http://blog.csdn.net/s030702614/article/details/5683928 1. 主函数: int main (int argc, char *argv[]) ...