博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU2519:新生晚会
阅读量:4323 次
发布时间:2019-06-06

本文共 1615 字,大约阅读时间需要 5 分钟。

Problem Description
开学了,杭电又迎来了好多新生。ACMer想为新生准备一个节目。来报名要表演节目的人很多,多达N个,但是只需要从这N个人中选M个就够了,一共有多少种选择方法?
 
Input
数据的第一行包括一个正整数T,接下来有T组数据,每组数据占一行。 每组数据包含两个整数N(来报名的人数,1<=N<=30),M(节目需要的人数0<=M<=30)
 
Output
每组数据输出一个整数,每个输出占一行
 
Sample Input
 
5 3 2 5 3 4 4 3 6 8 0
 
Sample Output
 
3 10 1 0 1
 
//第一遍,wa了。。。是int冒了的缘故
1 #include 
2 3 using namespace std; 4 int a,b; 5 double zh(int a,int b) 6 { 7 int up=1,down=1; 8 for(int i=1;i<=b;i++) 9 {up=up*a;a--;}10 for(int i=1;i<=b;i++)11 down=down*i;12 return up/down;13 }14 15 int main()16 {17 int i;18 cin>>i;19 while(i--)20 {21 cin>>a>>b;22 cout<
<

//第二遍。。采用一边算一边除的方法。。。

//自己好弱啊!!!又错了。。。

//有点意思(去死

1 #include 
2 #include
3 using namespace std; 4 long long a,b; 5 double zh(long long a,long long b) 6 { 7 double ans=1.0; 8 long long j=b; 9 while(j--)10 {11 ans=ans*a/b;12 a--;b--;13 }14 return ans;15 }16 17 18 int main()19 {20 int n;21 cin>>n;22 while(n--)23 {24 cin>>a>>b;25 cout<
<

//错误点。。。double不能cout,,,应该printf

#include 
#include
using namespace std;long long a,b;double zh(long long a,long long b){ double ans=1.0; long long j=b; while(j--) { ans=ans*a/b; a--;b--; } return ans;}int main(){ int n; cin>>n; while(n--) { cin>>a>>b; printf("%.0lf\n",zh(a,b)); } return 0;}

 

转载于:https://www.cnblogs.com/nefu929831238/p/5201959.html

你可能感兴趣的文章
BZOJ 1412 [ZJOI2009]狼和羊的故事 | 网络流
查看>>
原型模式
查看>>
Hadoop RPC源码阅读-交互协议
查看>>
WASAPI、DirectSound/DS、WaveOut、Kernel Streaming/KS
查看>>
Perl按行分割文件
查看>>
根据现有表操作基于active record的model
查看>>
NotMapped属性特性
查看>>
Count and Say
查看>>
GridView数据导入Excel/Excel数据读入GridView
查看>>
566. Reshape the Matrix
查看>>
python数据结构与算法之搜索
查看>>
(最小点覆盖) poj 2226
查看>>
(树形DP) poj 3659
查看>>
获取类的属性名和值
查看>>
python对json的操作总结
查看>>
学习进度表第十一周
查看>>
js屏蔽回车键
查看>>
Memcached通用类(基于enyim.com Memcached Client)
查看>>
c#组元(Tuple)的使用
查看>>
【NO.66】转 Yahoo的军规条例
查看>>