UVA 题目10910 Marks Distribution(组合数学)
来源:互联网 发布:淘宝上卖的淘宝推广 编辑:程序博客网 时间:2024/05/14 16:19
In an examination one student appeared in N subjects and has got total T marks. He has passed in
all the N subjects where minimum mark for passing in each subject is P. You have to calculate the
number of ways the student can get the marks. For example, if N = 3, T = 34 and P = 10 then the
marks in the three subject could be as follows.
Subject 1 Subject 2 Subject 3
1 14 10 10
2 13 11 10
3 13 10 11
4 12 11 11
5 12 10 12
6 11 11 12
7 11 10 13
8 10 11 13
9 10 10 14
10 11 12 11
11 10 12 12
12 12 12 10
13 10 13 11
14 11 13 10
15 10 14 10
So there are 15 solutions. So F(3, 34, 10) = 15.
Input
In the first line of the input there will be a single positive integer K followed by K lines each containing
a single test case. Each test case contains three positive integers denoting N, T and P respectively.
The values of N, T and P will be at most 70. You may assume that the final answer will fit in a
all the N subjects where minimum mark for passing in each subject is P. You have to calculate the
number of ways the student can get the marks. For example, if N = 3, T = 34 and P = 10 then the
marks in the three subject could be as follows.
Subject 1 Subject 2 Subject 3
1 14 10 10
2 13 11 10
3 13 10 11
4 12 11 11
5 12 10 12
6 11 11 12
7 11 10 13
8 10 11 13
9 10 10 14
10 11 12 11
11 10 12 12
12 12 12 10
13 10 13 11
14 11 13 10
15 10 14 10
So there are 15 solutions. So F(3, 34, 10) = 15.
Input
In the first line of the input there will be a single positive integer K followed by K lines each containing
a single test case. Each test case contains three positive integers denoting N, T and P respectively.
The values of N, T and P will be at most 70. You may assume that the final answer will fit in a
standard 32-bit integer.
Output
For each input, print in a line the value of F(N, T, P).
Sample Input
2
3 34 10
3 34 10
Sample Output
15
15
题目大意:m大的数,分成n组,每组最少k个,问有多少种方法
思路:先把每组放k个,然后剩下的再放到n组中(可有可无),相当于n+m组,分成n组,插n-1个空,即从n+m-1个空中选n-1个空
ac代码
#include<stdlib.h>#include<string.h>#include<iostream>#include<algorithm>#include<stdio.h>#include<math.h>#include<limits.h>#define N 100010#define mod 1000000#define LL long longusing namespace std;LL C(LL a,LL b){ LL ans=1; LL i; if(b>a/2) b=a-b; for(i=1;i<=b;i++) { ans*=(a-i+1); ans/=i; } return ans;}int main(){ int t; scanf("%d",&t); while(t--) { LL n,m,k; scanf("%lld%lld%lld",&n,&m,&k); m=m-n*k; printf("%lld\n",C(n+m-1,n-1)); }}
0 0
- UVA 题目10910 Marks Distribution(组合数学)
- UVA 10910 Marks Distribution(组合数学 或 递推)
- UVA 10910 Marks Distribution(组合数学 或 递推)
- Uva-10910-Marks Distribution
- UVA 10910 Marks Distribution
- UVa:10910 Marks Distribution
- UVa 10910 - Marks Distribution
- UVA - 10910 Marks Distribution
- UVa 10910 - Marks Distribution
- uva 10910Marks Distribution
- uva 10910 - Marks Distribution(dp)
- UVa 10910 Marks Distribution (可重复组合数)
- UVA 10910 - Marks Distribution (dp)
- UVA - 10910 Marks Distribution 简单DP
- UVA10910 - Marks Distribution(dp)
- Marks Distribution
- uva10910 - Marks Distribution
- HDOJ题目1220 Cube(组合数学)
- 系统学习机器学习之维度归约
- 【PostgreSQL】PostgreSQL基础操作
- 第16周项目1-归并排序(7)
- 第十四周(项目二)--判断二叉排序树
- 欢迎使用CSDN-markdown编辑器
- UVA 题目10910 Marks Distribution(组合数学)
- PHP IMG2TXT 图片转成文字
- 第八周 项目三 顺序串算法(3)
- C++ STL 迭代器失效
- 第十二周项目四----利用遍历思想求解图问题之7最远顶点
- Xcode 6之后创建PCH文件
- sqoop工具在hive和mysql之间互相导数据
- activity的生命周期
- 用十条命令在一分钟内检查Linux服务器性能