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 ...
随机推荐
- v-for的简单实现
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- (排班表二)后台动态绘制Grid表格
后台动态绘制值班表(Grid表格 列名不固定) 要求:表头除了值班人姓名,还要显示日期,及每天的星期值,用斜杠‘/’分隔.即:几号/星期几 最终实现的效果:根据查询的年月显示每个值班人查询月份每天的值 ...
- tcp回显客户端发送的数据
客户端: import socket tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcp_socket.connect ...
- BAT及各大互联网公司2014前端笔试面试题
很多面试题是我自己面试BAT亲身经历碰到的.整理分享出来希望更多的前端er共同进步吧,不仅适用于求职者,对于巩固复习前端基础更是大有裨益. 而更多的题目是我一路以来收集的,也有往年的,答案不确保一定正 ...
- easypoi 一行代码搞定excel导入导出
开发中经常会遇到excel的处理,导入导出解析等等,java中比较流行的用poi,但是每次都要写大段工具类来搞定这事儿,此处推荐一个别人造好的轮子[easypoi],下面介绍下“轮子”的使用. pom ...
- [Bzoj2286]消耗战(虚树+DP)
Description 题目链接 Solution 在虚树上跑DP即可 Code #include <cstdio> #include <algorithm> #include ...
- ABAP 7.51 構文書き方変換について
便利になったなぁと感じたコマンドのメモです.NetWeaver7.40 SP2から使えます. SAP NetWeaver AS for ABAP 7.51 Innovation Package – O ...
- PHP.25-TP框架商城应用实例-后台2-商品列表页-搜索、翻页、排序
商品列表页 1.翻页 控制器GoodsController.class.php添加方法lst(),显示列表页 在商品模型GoodsModel.class.php类中添加search方法 /** *实现 ...
- 内置函数--sorted,filter,map
sorted() 排序函数. 语法: sorted(Iterable, key=None, reverse=False) Iterable: 可迭代对象; key: 排序规则(排序函数); reve ...
- SpringMVC---springMVC配置文件(springweb.xml)简介
再web.xml中设置HTTP请求的中央调度处理器DispatcherServlet时,会指定SpringMVC配置文件,这里取名springweb.xml是因设置DispatcherServlet时 ...