题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1570

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

解题思路:组合和全排列!(水题~)

AC代码:

 #include<bits/stdc++.h>
using namespace std;
int main()
{
int T,n,m,sum;
char ch;
cin>>T;
while(T--){
getchar();//吃掉回车符
cin>>ch>>n>>m;
if(m>n)swap(n,m);//保证m比n小
sum=;//计数
if(ch=='A')for(int i=m;i>=;i--)sum*=(n-i+);//全排列
if(ch=='C'){//组合
if(n-m<m)m=n-m;//取m最小,减少计算
for(int i=;i<=m;i++)sum=sum*(n-i+)/i;
}
cout<<sum<<endl;
}
return ;
}

题解报告:hdu 1570 A C的更多相关文章

  1. 题解报告:hdu 1398 Square Coins(母函数或dp)

    Problem Description People in Silverland use square coins. Not only they have square shapes but also ...

  2. 题解报告:hdu 2069 Coin Change(暴力orDP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Problem Description Suppose there are 5 types of ...

  3. 题解报告:hdu 1028 Ignatius and the Princess III(母函数or计数DP)

    Problem Description "Well, it seems the first problem is too easy. I will let you know how fool ...

  4. 2015浙江财经大学ACM有奖周赛(一) 题解报告

    2015浙江财经大学ACM有奖周赛(一) 题解报告 命题:丽丽&&黑鸡 这是命题者原话. 题目涉及的知识面比较广泛,有深度优先搜索.广度优先搜索.数学题.几何题.贪心算法.枚举.二进制 ...

  5. cojs 强连通图计数1-2 题解报告

    OwO 题目含义都是一样的,只是数据范围扩大了 对于n<=7的问题,我们直接暴力搜索就可以了 对于n<=1000的问题,我们不难联想到<主旋律>这一道题 没错,只需要把方程改一 ...

  6. cojs 二分图计数问题1-3 题解报告

    OwO 良心的FFT练手题,包含了所有的多项式基本运算呢 其中一部分解法参考了myy的uoj的blog 二分图计数 1: 实际是求所有图的二分图染色方案和 我们不妨枚举这个图中有多少个黑点 在n个点中 ...

  7. CF Educational Round 78 (Div2)题解报告A~E

    CF Educational Round 78 (Div2)题解报告A~E A:Two Rival Students​ 依题意模拟即可 #include<bits/stdc++.h> us ...

  8. CF1169(div2)题解报告

    CF1169(div2)题解报告 A 不管 B 首先可以证明,如果存在解 其中必定有一个数的出现次数大于等于\(\frac{m}{2}\) 暴力枚举所有出现次数大于等于$\frac{m}{2} $的数 ...

  9. CFEducational Codeforces Round 66题解报告

    CFEducational Codeforces Round 66题解报告 感觉丧失了唯一一次能在CF上超过wqy的机会QAQ A 不管 B 不能直接累计乘法打\(tag\),要直接跳 C 考虑二分第 ...

  10. CF Round #580(div2)题解报告

    CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然 ...

随机推荐

  1. 【Arcgis Server】程序动态发布MXD到Arcgis Server

    http://dkay.blogbus.com/logs/47727282.html protected void Button14_Click(object sender, EventArgs e) ...

  2. 【转】apache storm 内置的定时机制

    原文:http://www.cnblogs.com/kqdongnanf/p/4778672.html ------------------------------------------------ ...

  3. 配置activeMQ

    一.加入以下的库 并配置好路径 ws2_32.lib;Mswsock.lib;cppunit.lib;libapr-1.lib;libapriconv-1.lib;libaprutil-1.lib;l ...

  4. HTC 328T 提示手机存储不足 out of space怎么办

    不要再用什么软件做优化,做清理,都是治标不治本啊. 1 用豌豆荚备份数据   2 手机恢复出厂设置   3 用豌豆荚恢复数据

  5. 微信小程序实战之 goods(订餐页)

    项目目录: 模拟数据: utils / data.js function getSData() { var data = [ { "name": "热销榜", ...

  6. 工作总结 js 选择器选择多条元素 支持一起设置他们属性 $("#edumes input[type='radio']").prop("checked", false);

    $("#edumes input[type='radio']").prop("checked", false); $("#edumes input[t ...

  7. React Native入门——布局实践:开发京东client首页(一)

    有了一些对React Native开发的简单了解,让我们从实战出发.一起来构建一个简单的京东client. 这个client是仿照之前版本号的京东client开发的Android版应用,来源于CSDN ...

  8. e3 cpu

    英特尔® 至强® E3 处理器 https://www.intel.cn/content/www/cn/zh/products/processors/xeon/e3-processors.html?p ...

  9. JAVA程序员常用软件整理

    Java类软件:-------------------------------JDK7.0:http://pan.baidu.com/s/1jGFYvAYMyclipse8.5破解版:http://p ...

  10. 设计模式-(8)外观(swift版)

    一,概念 为子系统中的一组接口提供一个统一的接口.外观模式定义了一个更高层次的接口,这个接口使得这一子系统更加容易使用. 二,结构图 (1)SubSystem子系统类:每个子系统定义了相关功能和模块的 ...