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. delphi 压缩ZLib

    system.ZLib http://docwiki.embarcadero.com/CodeExamples/Berlin/en/ZLibCompressDecompress_(Delphi) 还不 ...

  2. ntpdate server时出错原因及解决

    错误1.Server dropped: Strata too high 在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronizati ...

  3. vim之pydiction插件

    [vim之pydiction插件] It consists of three main files: python_pydiction.vim -- Vim plugin. complete-dict ...

  4. [网络]远程访问局域网svn服务器[转]

    转至:http://8474832.blog.51cto.com/8464832/1555449 打开路由器访问界面 选择转发规则->端口映射-新建 在弹出的界面中填写相应的端口号了内网ip 填 ...

  5. CentOS6 下Vim安装和配置

    1.系统只安装了vim-minimal,执行以下命令安装另外两个组件 yum install vim-common yum install vim-enhanced 2.安装ctags yum ins ...

  6. HttpRequest Get Post,WebClient Get

    #region HttpRequestGet public string HttpRequestGet(string url) { return HttpRequestGet(url, WebRequ ...

  7. UIWebView 获取当前的javascript上下文,并js,oc互调

    OC调用UIWebView 中的js,网上例子很多,最常用的是UIWebView自带的一个方法: - (NSString *)stringByEvaluatingJavaScriptFromStrin ...

  8. git免登录-ssh-key

    1.生成ssh key公钥与私钥 ssh-keygen -t rsa -C "youname@example.com" 需输入三个内容:第一个,生成公私钥的路径及名称:后两个输入回 ...

  9. cocos2d制作动态光晕效果基础——blendFunc

    转自:http://www.2cto.com/kf/201207/144191.html 最近的项目要求动态光晕的效果. 何谓动态光晕?之前不知道别人怎么称呼这个效果, 不过在我看来,“动态光晕”这个 ...

  10. WSB备份到远程共享文件夹的限制

    WSB备份存储类型: 远程共享文件夹: 可以将一次性(临时)备份和计划备份存储在远程共享文件夹上.(将计划备份存储在远程共享文件夹上的功能是 Windows Server 2008 R2 的新增功能. ...