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 ...
随机推荐
- 通过IIS共享文件夹来实现静态资源"本地分布式"部署
以下以文件型数据库(如sqlite)为例 楼主话:以下内容,若有不专业处,大胆喷,虚心求教. 起因:要进行一个项目的分布式部署,而这个项目所涉及的其中一个数据库为sqlite(经测试,同为文件型数据库 ...
- 9.5web service基础知识
Web服务基础 用户访问网站的基本流程 我们每天都会用web客户端上网,浏览器就是一个web客户端,例如谷歌浏览器,以及火狐浏览器等. 当我们输入www.oldboyedu.com/时候,很快就能看到 ...
- Apache 多端口配置方法
首先修改httpd.conf配置文件. 添加8080端口 Listen 8080 打开虚拟配置文件 # Virtual hosts Include conf/extra/httpd-vhosts.co ...
- 为 DirectAccess 设计 DNS 基础结构
TechNet 库Windows ServerWindows Server 2008 R2 und Windows Server 2008浏览 Windows Server 技术NetworkingD ...
- 云计算之路-阿里云-分享:通过RDS备份文件恢复SQL Server数据库
应用场景:假如您用了阿里云的SQL Server RDS,想在另外一台服务器上通过备份文件还原数据库至之前的某个时间点. 准备工作:准备1台用于还原的服务器,安装好SQL Server(2008或20 ...
- Javascript在浏览器中的加载顺序详解!
现在前端用javascript用的比较多,当然真心的说这个语言是一个非常业余的语言,但是用的人很多,所以也比较火.今天想完成一个javascript外部文件自动加载的设计(类似于java或者php的i ...
- CentOS修改IP地址
一.CentOS 修改IP地址修改对应网卡的IP地址的配置文件 # vi /etc/sysconfig/network-scripts/ifcfg-eth0 电信 # vi /etc/syscon ...
- KMP与循环节相关题目
HDU 3746 Cyclic Nacklace ( KMP求最小循环节 ) len - nextval[len]即为最小循环节长度. #include <cstdio> #include ...
- windows系统设备管理器显示全部硬件
下面的小命令能让隐藏的未卸载掉的硬件设备彻底现身:开始-运行-CMD C:\> C:\>start devmgmt.msc 之后再在Windows 的设备管理器中,单击菜单“显示”-“显示 ...
- 多线程 线程池 ExecutorService
package org.zln.thread; import java.util.Date; import java.util.concurrent.ExecutorService; import j ...