A C

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3107    Accepted Submission(s): 2008

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

Author
linle

Source
HDU 2007-1 Programming Contest

Recommend
linle

#include<stdio.h>
int frac[11]={1,1,2,6,24,120,720,5040,40320,362880,3628800};
int main()
{
int n,m,T;
char ch;
scanf("%d",&T);ch=getchar();
while (T--)
{
scanf("%c%d%d",&ch,&n,&m);
if (ch=='A') printf("%d\n",frac[n]/frac[n-m]);
else printf("%d\n",frac[n]/frac[m]/frac[n-m]);
ch=getchar();
}
return 0;
}

A C[HDU1570]的更多相关文章

  1. hdu1570(排列和组合公式的应用)

    题意: 给出字符A.则求全排列 A(n,m)=n!/(n-m)! 给出字符C.则求全组合 C(n,m)=n!/(m!*(n-m)!) http://acm.hdu.edu.cn/showproblem ...

  2. OJ题目分类

    POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006 POJ1008 POJ1013 P ...

  3. ACM~排列组合&amp;&amp;hdu例子

    排列组合是数学中的一个分支.在计算机编程方面也有非常多的应用,主要有排列公式和组合公式.错排公式.母函数.Catalan Number(卡特兰数)等. 一.有关组合数学的公式 1.排列公式   P(n ...

随机推荐

  1. HDU 4920 Matrix multiplication (硬件优化)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4920 解题报告:求两个800*800的矩阵的乘法. 参考这篇论文:http://wenku.baidu ...

  2. 搭建Nginx+JAVA环境

    搭建Nginx+JAVA环境 Apache对Java的支持很灵活,他们的结合度也很高,例如Apache+Tomcat和Apache+resin等都可以实现对Java应用的支持.Apache一般采用一个 ...

  3. linux下vim的常用指令

    进入vi的命令 vi filename :打开或新建文件,并将光标置于第一行首 vi +n filename :打开文件,并将光标置于第n行首 vi + filename :打开文件,并将光标置于最后 ...

  4. HDU 1713 最小公倍数与最大公约数的问题 相遇周期

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) 相遇周期 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/ ...

  5. Nginx和PHP-FPM的启动/重启脚本 [转发]

    Nginx和PHP-FPM的启动/重启脚本 [转发] (2012-07-27 16:07:52) 标签: it 分类: 学习 转载自:http://blog.sina.com.cn/s/blog_53 ...

  6. 20. 最长公共子串(ToDo)[LCS]

    [参考] http://zhedahht.blog.163.com/blog/static/254111742007376431815/

  7. Linux下配置JDK

    下面以CentOS为例,详细说一下Linux下配置JDK的过程 首先按照约定俗成的习惯,将jdk放在/usr/local/java下,首先进入/usr/local然后新建一个目录java 然后我们需要 ...

  8. Java for LeetCode 054 Spiral Matrix

    Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...

  9. 【python】

    1.修改系统默认编码: reload(sys) sys.setdefaultencoding('utf-8') 为什么在sys.setdefaultencoding之前要写reload(sys) 因为 ...

  10. docke跨主机通信之gre隧道

    GRE简介 GRE可以对网络层的任何协议来进行封装,类似LVS的IPIP协议,在原有的数据报上增加GRE协议数据报.然后在网络上传输,到达对端后,解开GRE数据报头,得到真实的数据报.其中的mac地址 ...