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. Stanford机器学习---第五讲. 神经网络的学习 Neural Networks learning

    原文 http://blog.csdn.net/abcjennifer/article/details/7758797 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回归 ...

  2. 第一次学习QT

    跟着大神学:http://www.cnblogs.com/tornadomeet/archive/2012/06/25/2561007.html

  3. c# 如何使用wlanapi连接电脑到wifi

    http://www.codeproject.com/Articles/72105/Manage-WiFi-with-Native-API-WIFI-on-Windows-XP-SP Introduc ...

  4. Rehashing

    The size of the hash table is not determinate at the very beginning. If the total size of keys is to ...

  5. C++文件输入输出

    #include <iostream> //有些系统里面可以省略此头文件 #include <fstream> #include <string> int main ...

  6. Html5 History API解析

    浏览器前进与回退操作 在传统的浏览器中我们只能通过调用window.history对象的 forward() . back() 或 go(number|url) 方法来进行页面的前进.回退或跳转到某一 ...

  7. ReverseString

    [本文链接] http://www.cnblogs.com/hellogiser/p/reverse-string.html reverse string [代码]  C++ Code  123456 ...

  8. Android 中“TabBar”的背景拉伸问题

    在最近的一个工程中,要求有一个在上方了tabbar,上面有并排的3个方形按钮,每个按钮都有背景图.问题来了,如何让图片在不同尺寸的屏幕上不失真呢?(由于我们的项目比较小,工时很短,不能为每一个屏幕尺寸 ...

  9. 单个php页面实现301重定向

    301重定向的意思是页面永久性移走,实现方式是当用户请求页面时,服务器返回相应http数据流头信息状态码为301,表示本网页永久性转移到另一个地址,301重定向是页面永久性转移,一般用在不打算改变的地 ...

  10. Python多线程(2)——线程同步机制

    本文介绍Python中的线程同步对象,主要涉及 thread 和 threading 模块. threading 模块提供的线程同步原语包括:Lock.RLock.Condition.Event.Se ...