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. System.IO 二

    接着上篇的来  System.IO FileSystemWatcher    指向这个签名的方法   可以监听目录发生了什么事件 例如: static void Main(string[] args) ...

  2. js动画效果

    js能够按照预定的时间间隔重复调用一个函数,而这意味着我们可以随着时间的推移而不断改变某个元素的样式.动画是样式随时间变化的完美例子之一. js函数setTimeout能够让某个函数在经过一段预定的时 ...

  3. Oracle SCN与时间的相互转换

    1.SCN转换成时间 select scn_to_timestamp(current_scn) from v$database; 2.时间转换成SCN select timestamp_to_scn( ...

  4. 在windows7上配置xampp虚拟主机

    在设置之前最好关闭xampp1.修改hosts文件进入C:\Windows\System32\drivers\etc目录,找到hosts文件.在# Localhost (DO NOT REMOVE) ...

  5. Linux平台下卸载MySQL的方法

    转载自: https://www.cnblogs.com/taomylife/p/7234925.html Linux平台下卸载MySQL的方法: MySQL的安装主要有三种方式:二进制包安装.RPM ...

  6. Maven - 依赖范围<scope></scope>

    6种:

  7. Linux nohup 关闭终端的时候,程序依然能在后台运行( linux重定向及nohup不输出的方法)

    先说一下linux重定向: 0.1和2分别表示标准输入.标准输出和标准错误信息输出,可以用来指定需要重定向的标准输入或输出.在一般使用时,默认的是标准输出,既1.当我们需要特殊用途时,可以使用其他标号 ...

  8. 用js控制单选框或者多选框问题

    出现如图问题时,这时不能用attr方法添加checked属性了,改用$( "input" ).prop( "checked", true ),完美解决.

  9. linux无名管道

    特点 无名管道是半双工的,也就是说,一个管道要么只能读,要么只能写 只能在有共同祖先的进程间使用(父子进程.兄弟进程.子孙进程等) fork或者execve调用创建的子进程,继承了父进程的文件描述符 ...

  10. JVM——九大工具助你玩转Java性能优化

    本文转载自 http://www.importnew.com/12324.html 本文由 ImportNew - 陈 晓舜 翻译自 idrsolutions.欢迎加入翻译小组.转载请参见文章末尾的要 ...