Marks Distribution

Time limit: 3.000 seconds

In an examination one student appeared in N subjects and has got total T marks. He has passed in all the Nsubjects 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=3T=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 NT and P respectively. The values of NT 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

思路:过程的最后一步为前n门课总分为j的种类;

    最后一步的子问题为:前n-1门课总分为j-k的种类;

    显然;k>=p&&k<=j-p*(n-1);(保证每门课都能取到最低值);

    状态转移方程为:dp[i][j]+=dp[i-1][j-k];

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define PI 3.141592653589792128462643383279502
int dp[][];
int n;
int main(){
//#ifdef CDZSC_June
//freopen("in.txt","r",stdin);
//#endif
//std::ios::sync_with_stdio(false);
cin>>n;
int N,T,P;
while(n--){
cin>>N>>T>>P; memset(dp,,sizeof(dp));
for(int i=;i<=;i++)dp[][i]=;
for(int i=;i<=N;i++)
for(int j=P;j<=T;j++){
for(int k=P;k<=j-P*(i-);k++)
dp[i][j]+=dp[i-][j-k];
}
cout<<dp[N][T]<<endl;
}
return ;
}

uva 10910(子集和问题)的更多相关文章

  1. uva 10910

    简单dp /************************************************************************* > Author: xlc2845 ...

  2. UVA 10910 Marks Distribution

    题意 把数字T分成N个数的和,保证这N个数中最小的数大于P.求方案数目 另f[i][j]表示把i分成j个数的和的方案数 f[i][j]=f[i][j-1]+f[i-1][j-1]+f[i-2][j-1 ...

  3. uva 11825 Hackers&#39; Crackdown (状压dp,子集枚举)

    题目链接:uva 11825 题意: 你是一个黑客,侵入了n台计算机(每台计算机有同样的n种服务),对每台计算机,你能够选择终止一项服务,则他与其相邻的这项服务都终止.你的目标是让很多其它的服务瘫痪( ...

  4. UVa 11825 - Hackers' Crackdown DP, 枚举子集substa = (substa - 1)&sta 难度: 2

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  5. UVA 1508 - Equipment 状态压缩 枚举子集 dfs

    UVA 1508 - Equipment 状态压缩 枚举子集 dfs ACM 题目地址:option=com_onlinejudge&Itemid=8&category=457& ...

  6. UVA 11825 - Hackers&#39; Crackdown 状态压缩 dp 枚举子集

    UVA 11825 - Hackers' Crackdown 状态压缩 dp 枚举子集 ACM 题目地址:option=com_onlinejudge&Itemid=8&page=sh ...

  7. UVA 11825 Hackers’ Crackdown(集合动态规划 子集枚举)

    Hackers’ Crackdown Miracle Corporations has a number of system services running in a distributed com ...

  8. Equipment UVA - 1508(子集补集)

    The Korea Defense and Science Institute, shortly KDSI, has been putting constant effort into newequi ...

  9. uva 11825 巧妙地子集枚举方法

    https://vjudge.net/problem/UVA-11825 题目大意,有n台服务器,有n种服务,每台服务器都运行着所有的服务,一台服务器可以被攻击一次其中的一种服务,当你选择攻击某台服务 ...

随机推荐

  1. No cached version of ..... available for offline mode.

    I had same error...Please Uncheck the offline work in Settings. File => Settings => Build, Exe ...

  2. 基于FPGA的HDTV视频图像灰度直方图统计算法设计

    随着HDTV的普及,以LCD-TV为主的高清数字电视逐渐进入蓬勃发展时期.与传统CRT电视不同的是,这些高清数字电视需要较复杂的视频处理电路来驱动,比如:模数转换(A/D Converter).去隔行 ...

  3. [BZOJ1076][SCOI2008]奖励关解题报告|状压DP

    你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关.在这个奖励关里,系统将依次随机抛出k次宝物,每次你都可以选择吃或者不吃(必须在抛出下一个宝物之前做出选择,且现在决定不吃的宝物以后也不能再吃). 宝 ...

  4. MSSQL 基础知识001

    数据库概述: DBMS(Database Management System,数据库管理系统)和数据库. 平时谈到“数据库”可能有两种含义:MSSQLServer.Oracle等某种DBMS:存放一堆 ...

  5. js跨域上传文件 iframe

    封装好的jq插件 (function () { var iframe = '<iframe name="jqUploadIframe" style="display ...

  6. setTimeOut、setInterval与clearInterval函数

    1.setTimeOut 在指定毫秒数后调用函数或计算表达式,函数或计算表达式只执行一次 setTimeout("alert('5 seconds!')",5000) 2.setI ...

  7. 概率DP入门学习QAQ

    emmmm博客很多都烂尾了...但是没空写..先写一下正在学的东西好了 概率DP这东西每次考到都不会..听题解也是一脸懵逼..所以决定学习一下这个东东..毕竟NOIP考过...比什么平衡树实在多了QA ...

  8. JS中,children和childNodes的不同之处

    <ul id="ul"><li></li><li></li><li><span></spa ...

  9. frp 使用入门

    1.下载安装对应系统版本 https://github.com/fatedier/frp/releases/ 2.将下载的frp移动到系统软件目录 mv frp/ /usr/local 3.配置frp ...

  10. 使用PTGui软件将全景图变成鱼眼图

    把全景图变成鱼眼图.方法一部分是自己研究的,一部分是参考学妹街景合成鱼眼照片的方法. 需要使用的软件是PTGui.是个收费软件,价格还不便宜.操作一下,安装完后就可以开始合成鱼眼图了. 加载图像 打开 ...