uva10910 - Marks Distribution
来源:互联网 发布:yy网络用语什么意思 编辑:程序博客网 时间:2024/05/21 06:19
URL: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1851
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=10then 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
Output for Sample Input
2
3 34 10
3 34 10
15
15
#include <cstdio>int k, n, t, p, dp[75][75];int main(){scanf("%d", &k); while(k--){ scanf("%d %d %d", &n, &t, &p); for(int i = p; i <= t; i++) dp[1][i] = 1; for(int i = 2; i <= n; i++) for(int j = p; j <= t; j++){ dp[i][j] = 0; for(int k = p; k <= j-p; k++) if(j-k >= p) dp[i][j] += dp[i-1][j-k]; } printf("%d\n", dp[n][t]); } return 0;}
- uva10910 - Marks Distribution
- UVA10910 - Marks Distribution(dp)
- 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
- uva10910
- UVA 10910 - Marks Distribution (dp)
- uva 10910 - Marks Distribution(dp)
- UVA - 10910 Marks Distribution 简单DP
- UVa 10910 Marks Distribution (可重复组合数)
- UVA 10910 Marks Distribution(组合数学 或 递推)
- UVA 10910 Marks Distribution(组合数学 或 递推)
- UVA 题目10910 Marks Distribution(组合数学)
- mongodb 备份 还原 导出 导入
- HDU 1421 搬寝室——动态规划
- MySQL常用SQL语句
- spring 工作原理
- Cocos2d-x 3.1.1 学习日志6--30分钟了解C++11新特性
- uva10910 - Marks Distribution
- 正则表达式
- poj 2828 线段树
- JSP简单练习-省略显示长字符串
- Android开发之解析XML-SAX
- Humidex
- [菜鸟]phpMyadmin修改密码后异常,error1045
- Codeforces Round #FF (Div. 2)
- 制作initramfs根文件系统内核并用其启动最终文件系统