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

Problem Description
Nowadays,
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).
 
Input
Input
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.
 
Output
For
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.
 
Sample Input
2
10 1
20 1
3
10 1
20 2
30 1
-1
 
Sample Output
20 10
40 40
 
Author
lcy
 
Recommend
We have carefully selected several similar problems for you:  2602 1203 2159 2955 2844
 
 
 
#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 母函数的更多相关文章

  1. 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 ...

  2. 组合数学 - 母函数的变形 --- hdu 1171:Big Event in HDU

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  3. hdu 1171 Big Event in HDU(母函数)

    链接:hdu 1171 题意:这题能够理解为n种物品,每种物品的价值和数量已知,现要将总物品分为A,B两部分, 使得A,B的价值尽可能相等,且A>=B,求A,B的价值分别为多少 分析:这题能够用 ...

  4. 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 ...

  5. HDU 1171 Big Event in HDU (多重背包变形)

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  6. HDU 1171 Big Event in HDU (多重背包)

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  7. 【01背包】HDU 1171 Big Event in HDU

    Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. Bu ...

  8. HDU 1171 Big Event in HDU dp背包

    Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s ...

  9. 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 ...

随机推荐

  1. Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9enuqi/MySQL-python/

    hu@hu-VirtualBox:/home/newdisk/telnet-scanner$ sudo pip install MySQL-python[sudo] hu 的密码: The direc ...

  2. 1、React-Native的基础入门

    React Native (简称RN)是Facebook于2015年4月开源的跨平台移动应用开发框架,是Facebook早先开源的JS框架 React 在原生移动应用平台的衍生产物,目前支持iOS和安 ...

  3. JavaScript提高容错的方式

    项目环境为Java Web项目,前端多用jquery,记录碰到的JS提高容错的编写方式. 回调的数据为null,数据绑定过程报错,影响下面代码执行 这种情况一开始想到的是能不能改用前端框架来动态的对页 ...

  4. FAT32中文版分析+补充(2)

    从Offset 36(0x24)开始FAT12/16的内容开始区别于FAT32,现在分两个表格列出来,下表为FAT12/16的内容: 名称 Offset(Byte) 大小(Byte) 描述 BS_dr ...

  5. lintcode_111_爬楼梯

    爬楼梯   描述 笔记 数据 评测 假设你正在爬楼梯,需要n步你才能到达顶部.但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部? 您在真实的面试中是否遇到过这个题? Yes 哪家公司问你的 ...

  6. Spring MVC 接收前端参数的方式

    方式一: 普通方式接收 1 @RequestMapping("/index") 2 public String getUserName(String username) { 3 S ...

  7. pip更改国内源

    国内源: 阿里云 http://mirrors.aliyun.com/pypi/simple/中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/豆瓣(dou ...

  8. python__高级 : Property 的使用

    一个类中,假如一个私有属性,有两个方法,一个是getNum , 一个是setNum 它,那么可以用 Property 来使这两个方法结合一下,比如这样用  num = property(getNum, ...

  9. PHP 7.1版本 微信安全模式消息接受

    token 验证就不多讲了 重点说一下PHP7.1版本的加密解密算法 php7.1发布后新特性吸引了不少PHPer,大家都在讨论新特性带来的好处与便利. 但是从php7.0 升级到 php7.1 废弃 ...

  10. VUE前端无法启动

    cd 到client中,使用npm run dev ,一直卡着也不报错,启动不了项目 可以直接使用 ,需要进入root目录进行 cnpm install npm -g