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. fdquery update

    fdquery  update this->FDQuery1->CachedUpdates; this->FDQuery1->UpdateOptions->KeyFiel ...

  2. 微软IOC容器Unity简单代码示例1

    @(编程) 1. 通过Nuget下载Unity 这个就不介绍了 2. 接口代码 namespace UnityDemo { interface ILogIn { void Login(); } } 3 ...

  3. linux下 ls 排序

    ls -lS                       按大小降序排列 ls -l | sort -n -k5    按大小升序 ls -lrt                       按时间降 ...

  4. Android PHP 通过JSON进行数据交互

    一.首先是Android客户端解析PHP返回的JSON数据 1.PHP代码(这里用到了数据库,如果没有准备数据库的话,可以自定义字符串) <?php $link=mysql_connect(SA ...

  5. 转载php在IIS中运行

    在IIS中配置PHP运行环境简单步骤 安装 IIS 7.0 打开 Control Panel\Programs\Programs and Features\Turn Windows features ...

  6. 编译安装-Nginx

    安装Nginx 1.环境准备 2.创建nginx用户 3.安装pcre-8.33.tar.gz 4.安装nginx-1.5.4.tar.gz 6.开机自启动 安装Nginx 1.环境准备 系统:Cen ...

  7. ASP.NET MVC- 解决HTML转码

    在MVC里从Controller发送一段带有HTML的文字到View视图时,MVC是会将这段代码进行转码的. 一.使用MvcHtmlString转HTML转码 如果想不让这段文字进行转码,以HTML的 ...

  8. [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server 不存在或访问被拒绝

    一般连接sql数据库,IP_connstr="driver={SQL Server}; server=127.0.0.1;database=数据库名字;uid=sa;pwd=密码" ...

  9. 在js中使用createElement创建HTML对象和元素

    1.创建链接 <script language="javascript"> var o = document.body; //创建链接 function createA ...

  10. GetSafeHwnd()函数解释[转]

    当我们想得到一个窗口对象(CWnd的派生对象)指针的句柄(HWND)时,最安全的方法是使用GetSafeHwnd()函数,通过下面的例子来看其理由: CWnd *pwnd = FindWindow(“ ...