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 ...
随机推荐
- 笔记-pytho-语法-yield
笔记-python-语法-yield 1. yield 1.1. yield基本使用 def fab(max): n,a,b = 0, 0, 1 while n < max: y ...
- python读取文件
请参考:http://www.cnblogs.com/sysuoyj/archive/2012/03/14/2395789.html
- Python 装饰器执行顺序迷思
Table of Contents 1. 探究多个装饰器执行顺序 1.1. 疑问 1.2. 函数和函数调用的区别 1.3. 装饰器函数在被装饰函数定义好后立即执行 1.4. 疑问的解释 2. 参考资料 ...
- MySQL数据库基础总结
来源: 实验楼 链接: https://www.shiyanlou.com/courses/9 一.开发准备 # 打开 MySQL 服务 sudo service mysql start #使用 ro ...
- Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support (LEMP) On Ubuntu 12.04 LTS [repost]
from : http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-lemp-on-ub ...
- GCD那些事儿
GCD GCD,全名Grand Central Dispatch,中文名郭草地,是基于C语言的一套多线程开发API,一听名字就是个狠角色,也是目前苹果官方推荐的多线程开发方式.可以说是使用方便,又不失 ...
- 《Cracking the Coding Interview》——第7章:数学和概率论——题目5
2014-03-20 02:20 题目:给定二维平面上两个正方形,用一条直线将俩方块划分成面积相等的两部分. 解法:穿过对称中心的线会将面积等分,所以连接两个中心即可.如果两个中心恰好重合,那么任意穿 ...
- JMeter学习笔记(四) HTTP Cookies 管理器
有些接口执行时,要求要先登录,此时就需要用到 HTTP Cookies 管理器.不过有些项目是使用的token,即添加HTTP信息头管理器,获取登录后的token,至于token与cookies的区别 ...
- ansible自动部署Keepalived实现Nginx服务双机热备
脚本实现通过ansible-playbook自动化安装Keepalived和配置,主要解决问题如下: Keepalived自动化安装: keepalived_vrid配置,自动根据vip获取最后一段作 ...
- CodeBlocks X64 SVN 编译版
CodeBlocks X64 SVN 编译版 采用官方最新的SVN源码编译而来,纯64位的,所以32位系统是不能使用的.字体使用的是微软的YaHei UI字体,如果有更好的字节建议,可以留言. 由于直 ...