题解报告:hdu 1570 A C
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1570
Problem Description
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
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
And print the answer in a single line.
Sample Input
Sample Output
解题思路:组合和全排列!(水题~)
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的更多相关文章
- 题解报告:hdu 1398 Square Coins(母函数或dp)
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
- 题解报告:hdu 2069 Coin Change(暴力orDP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Problem Description Suppose there are 5 types of ...
- 题解报告: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 ...
- 2015浙江财经大学ACM有奖周赛(一) 题解报告
2015浙江财经大学ACM有奖周赛(一) 题解报告 命题:丽丽&&黑鸡 这是命题者原话. 题目涉及的知识面比较广泛,有深度优先搜索.广度优先搜索.数学题.几何题.贪心算法.枚举.二进制 ...
- cojs 强连通图计数1-2 题解报告
OwO 题目含义都是一样的,只是数据范围扩大了 对于n<=7的问题,我们直接暴力搜索就可以了 对于n<=1000的问题,我们不难联想到<主旋律>这一道题 没错,只需要把方程改一 ...
- cojs 二分图计数问题1-3 题解报告
OwO 良心的FFT练手题,包含了所有的多项式基本运算呢 其中一部分解法参考了myy的uoj的blog 二分图计数 1: 实际是求所有图的二分图染色方案和 我们不妨枚举这个图中有多少个黑点 在n个点中 ...
- CF Educational Round 78 (Div2)题解报告A~E
CF Educational Round 78 (Div2)题解报告A~E A:Two Rival Students 依题意模拟即可 #include<bits/stdc++.h> us ...
- CF1169(div2)题解报告
CF1169(div2)题解报告 A 不管 B 首先可以证明,如果存在解 其中必定有一个数的出现次数大于等于\(\frac{m}{2}\) 暴力枚举所有出现次数大于等于$\frac{m}{2} $的数 ...
- CFEducational Codeforces Round 66题解报告
CFEducational Codeforces Round 66题解报告 感觉丧失了唯一一次能在CF上超过wqy的机会QAQ A 不管 B 不能直接累计乘法打\(tag\),要直接跳 C 考虑二分第 ...
- CF Round #580(div2)题解报告
CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然 ...
随机推荐
- centos No module named setuptools解决方案
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz tar zxvf setuptool ...
- [Unit Testing] Mock an HTTP request using Nock while unit testing
When testing functions that make HTTP requests, it's not preferable for those requests to actually r ...
- 理解Android线程创建流程(转)
/android/libcore/libart/src/main/java/java/lang/Thread.java /art/runtime/native/java_lang_Thread.cc ...
- 开源yYmVc项目,邀您和我一起开发:)
打算在闲暇时间写个MVC框架,要有什么功能一步一步边写边加,仿照struts 2 和 spring mvc.假设您感兴趣的话,能够私密我,给您加入key:). 欢迎您的到来~ 项目放在基于GIT的CS ...
- 使用mongostat监视mongodb
1, 监视一个mongod mongostat 10.80.1.1:27018 1,监视replica set mongostat --host rs0/10.80.1.1:27018,10.80.1 ...
- Vue调试工具 vue-devtools
vue-devtools是一款基于chrome浏览器的插件,可以帮我们快速调试vue项目 vue-devtools手动安装: 第一步:找到vue-devtools的github项目(https://g ...
- 解决UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 12: ordinal not in range(128)的编码问题
当我在运行一个基于scrapy的爬虫时出现UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 12: ordina ...
- ora-12541无监听的一种场景
项目上突然出现无法连接Oracle数据库的情况,提示无监听程序. 现象: 查看 listener.ora配置无问题,用Net Configuration Assistant重建监听,NCA也处于假死状 ...
- POJ2528 Mayor's posters —— 线段树染色 + 离散化
题目链接:https://vjudge.net/problem/POJ-2528 The citizens of Bytetown, AB, could not stand that the cand ...
- jquery a
<!DOCTYPE html><html><head><script src="//ajax.googleapis.com/ajax/libs/jq ...