[代码]
转载 2010-05-15 21:47:00
35阅读
2评论
CCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1intintcomp(int*x,int*y)2{3return*x-*y;4}56inta[1000000];7intmain(void)8{9inti,n=0;10while(scanf("%d"...
转载 2010-04-26 12:36:00
44阅读
2评论
pearls are very soft and need special care. they never should be tossed on top of or next to other gems in a jewelry box. store them in a jewelry pouch. some women's skin is more acidic than others. i
原创 2010-01-15 18:25:00
672阅读
题 题意 有n个(n≤100)等级的珍珠,等级越高单价越高,要购买一种等级的珍珠就要多付10*单价,现在需要购买一些等级的珍珠一定数量,若买更高等级的珍珠更便宜则可以买更高等级的珍珠,求最少花费。 分析 我原来想贪心(如果该等级买,不如后一等级多买那么多更优,那就不买该等级),然而是错的,怎么证明不
原创 2021-07-22 14:03:12
40阅读
题意:给出几类珍珠,以及它们的单价,要求用最少的钱就可以买到相同数量的,相同(或更高)质量的珍珠。规定买任一类的珍珠n个(价格为p),都要支付(n+10)*p的钱,即额外支付10*p。(1) 要求要买的珍珠的数量是一定的(2) 所买的珍珠的质量允许提高,但不允许下降(即可以用高质量珍珠替代低质量)(3) 输入时,后输入的珍珠价格一定比前面输入的要贵(4) 由(2)(3)知,珍珠的替代必须是连续的,不能跳跃替代。因为,假如方案是用第 i+2 类去替代第 i 类珍珠,而用第 i+1 类去替代第 i 类珍珠会使最终的支付价格更加低;所以,一定是因为第 i+2 类代替了第 i+1 类后会使最终的支付价
转载 2013-07-05 08:55:00
90阅读
2评论
题意:给出几类珍珠,以及它们的单价,要求用最少的钱就可以买
转载 2013-07-05 22:00:00
42阅读
#include <iostream> //DP#include <numeric>using namespace std;#define ed 105int ai[ed],pi[ed],dp[ed]; int main(){ int t,c; cin>>t; while(t--) { cin>>c; for(int i=1;i<=c;++i) cin>>ai[i]>>pi[i]; fill(dp,dp+ed,100000000); //初始化为极大值 dp[0]=0; for(int i=1;i<=c;++i
转载 2011-07-22 19:04:00
54阅读
2评论
http://poj.org/problem?id=1260 题意:给出几类珍珠,以及它们要买的数量和单价,珍珠的质量依次上升,价格也依次上升,计算买所有珍珠需要花的最少价格。 购买规则是这样的,不管买哪一类的珍珠,最后都需要增加10个该类珍珠,并且质量低的珍珠可以用质量高的珍珠来代替。 举个例子吧
转载 2017-02-01 15:29:00
36阅读
2评论
DP is, enumeration + pruning. If you can think of enumeratio
转载 2014-07-01 14:02:00
181阅读
2评论
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1300思路:简单DPAC代码:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3
原创 2022-08-04 09:21:49
42阅读
题意:有一些珍珠,给你珍珠的数量价格,你需要买下所有的珍珠,购买的方法买一种珍珠,设珍珠数量n 、价格 p,则须支付(
原创 2023-12-30 08:07:42
57阅读
DescriptionIn Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produce
原创 2023-04-24 07:39:23
64阅读
PearlsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7946 Accepted: 3948DescriptionIn Pearlania everybody is fond of pearls. One company, called The Ro
原创 2023-04-21 02:10:40
96阅读
自己想的,自己写的未成功。#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;int n;struct my{ int num; int v; bool operator<(my b)
原创 2023-07-27 18:44:04
55阅读
http://acm.hdu.edu.cn/showproblem.php?pid=5009借鉴题解:双向链表优化dp。dp[i]表示涂完前i个所化的最小代价,显然有dp[i]=min{dp[j]+num(j+1,i)^2},其中1<=j<i,num(j+1,i)表示区间[j+1,i]的颜色个数。这样复杂度为O(n^2)显然超时。那么需要优化一下,比如第二组测试数据3 4 2...
原创 2022-06-15 20:49:46
32阅读
PearlsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 894Accepted Submission(s): 382Problem DescriptionIn Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pearl has i
转载 2013-01-28 18:27:00
76阅读
PearlsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2018Accepted Submission(s): 953 Problem Des...
转载 2016-01-23 16:26:00
37阅读
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1300题目大意:珠宝店有100种不同质量的珍珠,质量越高价钱越高,为了促进销售,每买一种类型的珍珠,要在原来的基础上必须再买10个。这时一个CFO发现,这种条件下,有时买质量更好的反而更便宜。比如要买10元的珍珠5个,20元的珍珠100个,普通的买法需要(5+10)*10 + (100+10)*20 = 2350,但是如果只买105个价值20元的珍珠,只需要(5+100+10)*20 = 2300。现在给定要买的珍珠的数量和对应价格,求最少花费Sample Input22100 1100 231 1
转载 2013-09-09 20:45:00
69阅读
2评论
Problem Description In Pearlania everybody
原创 2023-02-24 10:21:44
69阅读
#include <iostream> //DP#include <numeric>using namespace std;#define ed 105int ai[ed],pi[ed],dp[ed]; int main(){ int t,c; cin>>t; while(t--) { cin>>c; for(int i=1;i<=c;++i) cin>>ai[i]>>pi[i]; fill(dp,dp+ed,100000000); //初始化为极大值 dp[0]=0; for(int i=1;i<=c;++i
转载 2011-07-21 01:43:00
56阅读
  • 1
  • 2
  • 3
  • 4
  • 5