题解报告: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\) 这是必须要满足的 既然 ...
随机推荐
- Visual Studio Visual assistant注释也做拼写检查怎么办
1 打开Visual Assistant 2 在Advanced中找到Underlines,取消勾选"Underline spelling errors in comments and ...
- C#趣味程序---百鸡百钱
问题:公鸡一仅仅5元,母鸡一仅仅3元,小鸡三仅仅1元.问100元能够买多少仅仅鸡? using System; namespace ConsoleApplication1 { class Progra ...
- oracle 重要函数
1)instr()函数的格式 (俗称:字符查找函数) 格式一:instr( string1, string2 ) / instr(源字符串, 目标字符串) 格式二:instr( string1, st ...
- Django项目开发-小技巧
当你开发完一个Django项目之后肯定要吧他丢到服务器让跑起来,但是你在自己的环境下安装了好多的包,是不是在服务器中也要一个个的安装了, pip freeze > read.txt #这条命令会 ...
- Cts框架解析(6)-任务的运行
前两篇讲了任务的加入和9大项配置,这篇讲任务的运行. 任务的运行 任务的运行在CommandScheduler的run方法中,所以删除全部的断点,在run方法中打上断点,重新启动启动debug: 先看 ...
- vue学习1
1.<div id="app">{{message}}<input v-model="message"></div>new ...
- 使用Python操作Redis应用场景
1. 安装pyredis 首先安装pip 1 2 3 4 5 6 7 8 <SHELL># apt-get install python-pip ...... <SHELL> ...
- 洛谷 P1313 计算系数 —— 水题
题目:https://www.luogu.org/problemnew/show/P1313 不就是...C(k,n) * an * bm . 代码如下: #include<iostream&g ...
- sharepoint2013安装AppFabric出错
手动安装AppFabric "d:\WindowsServerAppFabricSetup_x64.exe" /i CacheClient,CachingService,Cache ...
- org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.context.ContextLoaderListener
org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.context.ContextLoaderLi ...