HDU 1171 Big Event in HDU 母函数
Big Event in HDU
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28468 Accepted Submission(s): 10023
we all know that Computer College is the biggest department in HDU.
But, maybe you don't know that Computer College had ever been split into
Computer College and Software College in 2002.
The splitting is
absolutely a big event in HDU! At the same time, it is a trouble thing
too. All facilities must go halves. First, all facilities are assessed,
and two facilities are thought to be same if they have the same value.
It is assumed that there is N (0<N<1000) kinds of facilities
(different value, different kinds).
contains multiple test cases. Each test case starts with a number N (0
< N <= 50 -- the total number of different facilities). The next N
lines contain an integer V (0<V<=50 --value of facility) and an
integer M (0<M<=100 --corresponding number of the facilities)
each. You can assume that all V are different.
A test case starting with a negative integer terminates input and this test case is not to be processed.
each case, print one line containing two integers A and B which denote
the value of Computer College and Software College will get
respectively. A and B should be as equal as possible. At the same time,
you should guarantee that A is not less than B.
10 1
20 1
3
10 1
20 2
30 1
-1
40 40
#include<stdio.h>
#include<string.h>
int c[],temp[];
int num[],cost[];
int main(){
int n;
while(scanf("%d",&n)!=EOF){
if(n<)
break;
memset(c,,sizeof(c));
memset(temp,,sizeof(temp));
memset(num,,sizeof(num));
memset(cost,,sizeof(cost));
int sum=;
for(int i=;i<n;i++){
scanf("%d%d",&cost[i],&num[i]);
sum+=cost[i]*num[i];
} int total=sum/;
for(int i=;i<=num[];i++){
c[i*cost[]]=; 。///初始化的时候特别注意
} for(int i=;i<n;i++){
for(int j=;j<=sum;j++){
for(int k=;k+j<=sum&&k/cost[i]<=num[i];k+=cost[i])
temp[k+j]+=c[j];
} for(int ii=;ii<=sum;ii++){
c[ii]=temp[ii];
temp[ii]=; }
}
int i;
for( i=total;i>=;i--){
if(c[i])
break;
}
printf("%d %d\n",sum-i,i); }
return ;
}
HDU 1171 Big Event in HDU 母函数的更多相关文章
- HDU 1171 Big Event in HDU 多重背包二进制优化
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1171 Big Event in HDU Time Limit: 10000/5000 MS (Jav ...
- 组合数学 - 母函数的变形 --- hdu 1171:Big Event in HDU
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu 1171 Big Event in HDU(母函数)
链接:hdu 1171 题意:这题能够理解为n种物品,每种物品的价值和数量已知,现要将总物品分为A,B两部分, 使得A,B的价值尽可能相等,且A>=B,求A,B的价值分别为多少 分析:这题能够用 ...
- hdu 1171 Big Event in HDU (01背包, 母函数)
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU 1171 Big Event in HDU (多重背包变形)
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU 1171 Big Event in HDU (多重背包)
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- 【01背包】HDU 1171 Big Event in HDU
Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. Bu ...
- HDU 1171 Big Event in HDU dp背包
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s ...
- HDU 1171 Big Event in HDU【01背包/求两堆数分别求和以后的差最小】
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
随机推荐
- 数据库MySQL基本介绍安装使用及文件导入导出
1.数据库(data base) 1.1 简述 把文件存储在一台电脑上(服务器),其他电脑用户可以通过账号密码登陆,通过网络去访问这台电脑上的文件,但是由于每个人的数据是不同的,所以你只能通过自己的账 ...
- 12.1.0.2自适应特性导致SQL性能下降
背景介绍 在升级到12.1.0.2.0数据库版本后,在使用12c中引入的自适应特性默认配置的情况下,可能引起SQL性能的下降. 问题现象升级到12.1.0.2.0后,SQL语句性能可能出现下降. 影响 ...
- iOS MapKit地图
地图框架:#import <MapKit/MapKit.h> 基本属性和方法: 属性: 地图类视图:MKMapView 地图类型:MKMapType mapType 地图旋转:rotate ...
- LeetCode804. Unique Morse Code Words
题目 国际摩尔斯密码定义一种标准编码方式,将每个字母对应于一个由一系列点和短线组成的字符串, 比如: "a" 对应 ".-", "b" 对应 ...
- 【学时总结】◆学时·VII◆ 高维DP
◆学时·VII◆ 高维DP 自学之余,偶遇DP…… ◇ 算法概述 顾名思义——一种处理多方面状态的DP,这种DP特点是……每一维的大小都不算太大(不然用dp数组存储下来内存会炸),而且枚举时容易超时… ...
- 微信 php 获取token 第二次失败解决办法
第一次成功了,第二次总是失败,很简单,session问题 clearstatcache(); $_SESSION = ''; $_COOKIE = ''; //获得参数 signature nonce ...
- Servlet学习笔记03——什么是DAO?
1.案例 (1)添加用户 step1.建表 create table t_user( id int primary key auto_increment, username varchar(50) u ...
- oracle之bitmap索引
oracle常见的索引是BTree索引和Bitmap索引. BTree索引特点: 默认索引 适合大量增删改查 不能用or操作符 适合高基数的列(即唯一值多) 创建sql:create index li ...
- 生产-消费模式的synchronized和lock实现(十)
lock: package com.net.thread.lock; import java.util.concurrent.locks.Condition; import java.util.con ...
- GDOI--DAY2 游记
今天,熬夜不够多,果然,不出所料,爆零了... 第一题,看到数据之大,懵逼了,于是,敲了个二分SPFA,但是!最大的点GG了,呜呜~~~~(>_<)~~~~ ,于是,就不继续做第一题了(虽 ...