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. PPTP服务器配置选项详解

    导读 PPTP服务器配置文件的格式与其它许多Unix程序相似,每一行包含一项配置内容,以配置选项名称开始,后面紧跟参数值或者关键字,它们之间用空格分隔.在读取配置文件时,pptpd进程将忽略空行和每一 ...

  2. ios中的category与extension

    http://blog.csdn.net/haishu_zheng/article/details/12873151   category和extension用来做类扩展的,可以对现有类扩展功能或者修 ...

  3. FOJ 2161 Jason and Number

    暴力模拟找规律: 552287 2014-04-23 21:08:48 Accepted 2161 Visual C++ 0 ms 192KB 347B Watermelon #include< ...

  4. 07 DAY 1

    壮烈的一天... 第一题 本意是水题,然后写了块状数组模拟,最后发现算法错了... 然后其实快排一遍扫一遍完事... 100分 #include <cstdio> #include < ...

  5. 反转字符串--C和Python

    将字符串反转,即“abcde”->"edcba" C语言实现: [转自http://www.kanzhun.com/mianshiti/456.html?sid=mail_1 ...

  6. 【Other】推荐点好听的钢琴曲

    2013-12-13 16:19 匿名 | 浏览 138977 次 音乐钢琴 推荐点好听的钢琴曲,纯音乐也可以thanks!!! 2013-12-14 19:34 网友采纳 热心网友 巴洛克:帕海贝尔 ...

  7. Convert Sorted List to Balanced BST

    Given a singly linked list where elements are sorted in ascending order, convert it to a height bala ...

  8. poj_2674 弹性碰撞

    题目大意 给定一条直线,长度为L 表示区间[0, L].在直线上开始放置N个人,每个人有一个初始位置pos(用到直线上端点0的距离表示)和初始方向dir('p' 或 'P' 表示向端点L行走, 'n' ...

  9. 毫秒数转换为指定格式日期的js代码

    var format = function(time, format){ var t = new Date(time); var tf = function(i){return (i < 10 ...

  10. [Linux] xargs的- n1参数

    起因在对一堆*.tar.gz文件解压缩时,发现tar xvfz *.tar.gz不管用,一查,原来是tar xvfz *.tar.gz会被shell给拆成tar xvfz a.tar.gz b.tar ...