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]+...f[0][j-1];
f[i-1][j]=f[i-1][j-1]+f[i-2][j-1]+...f[0][j-1];
两式做差 推出f[i][j]=f[i-1][j]+f[i][j-1];
那么ans=f[T-NP][N];
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == ? b : gcd(b, a % b);}
#define MAXN 500
LL f[MAXN][MAXN];
int N,T,P;
void init()
{
for (int i=;i<MAXN;i++) for (int j=;j<MAXN;j++) f[i][j]=;
for (int i=;i<=;i++)
f[][i]=;
for (int i=;i<=;i++)
for (int j=;j<=;j++)
f[i][j]=f[i-][j]+f[i][j-];
}
int main()
{
init();
int kase;
scanf("%d",&kase);
while (kase--)
{
scanf("%d%d%d",&N,&T,&P);
if (T-N*P<) {puts("");continue;}
else printf("%lld\n",f[T-N*P][N]);
}
return ;
}
UVA 10910 Marks Distribution的更多相关文章
- uva 10910(子集和问题)
Marks Distribution Time limit: 3.000 seconds In an examination one student appeared in N subjects an ...
- uva 10910
简单dp /************************************************************************* > Author: xlc2845 ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- UVA - 11920 0 s, 1 s and ? Marks
Description 0 s, 1 s and ? Marks Given a string consisting of 0, 1 and ? only, change all the ? to ...
- 第八届河南省赛F.Distribution(水题)
10411: F.Distribution Time Limit: 1 Sec Memory Limit: 128 MB Submit: 11 Solved: 8 [Submit][Status] ...
- UVa 12525 Boxes and Stones (dp 博弈)
Boxes and Stones Paul and Carole like to play a game with S stones and B boxes numbered from 1 to B. ...
- 齐夫定律, Zipf's law,Zipfian distribution
齐夫定律(英语:Zipf's law,IPA英语发音:/ˈzɪf/)是由哈佛大学的语言学家乔治·金斯利·齐夫(George Kingsley Zipf)于1949年发表的实验定律. 它可以表述为: 在 ...
- CloudSim4.0报错NoClassDefFoundError,Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.distribution.UniformRealDistribution
今天下载了CloudSim 4.0的代码,运行其中自带的示例程序,结果有一部分运行错误: 原因是找不到org.apache.commons.math3.distribution.UniformReal ...
- Wishart distribution
Introduction In statistics, the Wishart distribution is generalization to multiple dimensions of the ...
随机推荐
- css3心形 perspective transform
CSS3挺有趣的,能实现不少动画,以下为娱乐内容 <!DOCTYPE html> <html> <head> <meta charset="UTF- ...
- bootstrap设计横线上加字
1.给横线上加字 . 2.思路:通过z-index实现,可以将父元素的z-index设置成2,而横线的z-index设置成-1,这样有字的地方就可以覆盖横线,再设置字的padding达到合理的宽度 ( ...
- TCP重组问题
今天问题: vqmon 测试一pcap抓包文件18.pcap.发现实际输出的视频分片信息和抓包不符合. ===>pts : 00:00:33 Too much data in TCP recei ...
- Java - 收藏集 -
Java - 收藏集 - Java 基础思维导图,让 Java 不再难懂 - 工具资源 - 掘金思维导图的好处 最近看了一些文章的思维导图,发现思维导图真是个强大的工具.了解了思维导图的作用之后, ...
- PQFitness
<html> <head> <title></title> <style> *{margin:o;padding:0;} #header{ ...
- Pascal小游戏 俄罗斯方块
俄罗斯方块已经成为了和“Hello World”一样的程序了吧? 不要直接复制,可能需要事先 Format. program cube;uses crt,graph,dos;var gd,gm:sma ...
- 去除文件夹中的.svn
一.在Dos窗口中运行如下命令 for/r <你项目的路径> %i in (.svn) do rd /s /q %i 二.将“Delete SVN Folders”操作添加到右击菜单中 建 ...
- 5.0 Genymotion安装以及基础使用
后续考虑到python+appium多设备并发执行,需要多台手机,所以这里就直接更新一个jenymotion,后续多设备执行直接用真机+模拟器操作!Genymotion第一步:百度搜索[Genymot ...
- Mini-MBA记录
最近学完了Mini-MBA的课程,对课程讲述的人力资源,创新,财务,战略,领导力等方面有了更深一些的了解,在此之上也做了一些笔记,如果课程信息披露是被允许的,后续把这些笔记贴出来,作为自己以后的参考.
- COMMIT和ROLLBACK的用法
从功能上划分,SQL语言可以分为DDL,DML和DCL三大类. 1.DDL(Data Definition Language) 数据定义语言,用于定义和管理 SQL 数据库中的所有对象的语言 : C ...