
贪心
lqybzx
123
展开
-
bzoj 1193: [HNOI2006]马步距离
DescriptionInput只包含4个整数,它们彼此用空格隔开,分别为xp,yp,xs,ys。并且它们的都小于10000000。Output含一个整数,表示从点p到点s至少需要经过的马步移动次数。Sample Input1 2 7 9Sample Output5第一眼看上去就可以知道是贪心了。大概可以推测出肯定原创 2015-01-06 22:11:49 · 1296 阅读 · 0 评论 -
2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String hdu5842
Problem DescriptionLweb has a string S.Oneday, he decided to transform this string to a new sequence. You need help him determine this transformation to get a sequence which has the longes原创 2016-08-14 23:06:48 · 439 阅读 · 0 评论 -
Codeforces Round Intel Code Challenge Final Round D. Dense Subsequence
题目大意:给你一个字符串,要求你选择若干个位置,使得任意相邻m个字符都至少有一个被选中,并且要求选中字符排序后的字典序列最小一开始写了个单调队列DP,然后WA5发现并不具有局部最优推到全局最优的性质洗澡的时候发现直接贪心就可以了。。洗完已经结束提交了我们从a到z顺次枚举,如果加上当前的所有字符都无法满足条件,那么就全部加进去,否则看当前字母最少需要选择几个即可最后统原创 2016-10-09 12:30:45 · 337 阅读 · 0 评论 -
Codeforces Round #373 (Div. 1) A.Efim and Strange Grade
题目大意:给你一个长度为n的数字,其中含有一个小数点,你可以做k次操作,每次操作可以让小数点后的某一位四舍五入并且舍去后面的数。问操作后可以得到的最大的数是多少当时忘记考虑进位到整数位上后不要输出小数点的情况了我们每次找最左边的一个大于5的数,进位,即可求出最大值#include#include#include#include#include#includ原创 2016-09-27 18:42:57 · 402 阅读 · 0 评论 -
hdu 5965 扫雷 2016ACM/CCPC合肥赛区现场赛E
Problem Description扫雷游戏是晨晨和小璐特别喜欢的智力游戏,她俩最近沉迷其中无法自拔。该游戏的界面是一个矩阵,矩阵中有些格子中有一个地雷,其余格子中没有地雷。 游戏中,格子可能处于己知和未知的状态。如果一个己知的格子中没有地雷,那么该 格子上会写有一个一位数,表示与这个格子八连通相邻的格子中地雷总的数量。现在,晨晨和小璐在一个3行N列(均从1开始用连续正整数编号)原创 2016-11-05 20:19:17 · 884 阅读 · 0 评论 -
hdu 5969 最大的位或 2016ACM/CCPC合肥赛区现场赛I
Problem DescriptionB君和G君聊天的时候想到了如下的问题。给定自然数l和r ,选取2个整数x,y满足l 其中|表示按位或,即C、 C++、 Java中的|运算。 Input包含至多10001组测试数据。第一行有一个正整数,表示数据的组数。接下来每一行表示一组数据,包含两个整数l,r。保证 0 1018。原创 2016-11-05 20:25:07 · 1001 阅读 · 0 评论 -
hdu 5914 Triangle 2016ACM/CCPC长春赛区现场赛D
Problem DescriptionMr. Frog has n sticks, whose lengths are 1,2, 3⋯n respectively. Wallice is a bad man, so he does not want Mr. Frog to form a triangle with three of the sticks here. He decides原创 2016-10-08 19:21:50 · 570 阅读 · 0 评论 -
hdu 5916 Harmonic Value Description 2016ACM/CCPC长春赛区现场赛F
Problem DescriptionThe harmonic value of the permutation p1,p2,⋯pn is∑i=1n−1gcd(pi.pi+1)Mr. Frog is wondering about the permutation whose harmonic value is the strictly k-th smallest amo原创 2016-10-08 19:24:05 · 629 阅读 · 0 评论 -
hdu 5918 Harmonic Value Description 2016ACM/CCPC长春赛区现场赛H
Problem DescriptionMr. Frog has two sequences a1,a2,⋯,an and b1,b2,⋯,bm and a number p. He wants to know the number of positions q such that sequence b1,b2,⋯,bm is exactly the sequence aq,aq+p原创 2016-10-08 19:26:13 · 531 阅读 · 0 评论 -
hdu 5920 Ugly Problem 2016ACM/CCPC长春赛区现场赛J
Problem DescriptionEveryone hates ugly problems.You are given a positive integer. You must represent that number by sum of palindromic numbers.A palindromic number is a positive integer su原创 2016-10-08 19:29:34 · 438 阅读 · 0 评论 -
hdu 6015 Skip the Class
Problem DescriptionFinally term begins. luras loves school so much as she could skip the class happily again.(wtf?)Luras will take n lessons in sequence(in another word, to have a chance to sk原创 2017-03-19 21:11:14 · 276 阅读 · 0 评论 -
hdu 6011 Lotus and Characters
Problem DescriptionLotus has n kinds of characters,each kind of characters has a value and a amount.She wants to construct a string using some of these characters.Define the value of a string is原创 2017-03-19 21:13:34 · 336 阅读 · 0 评论 -
hdu 6012 Lotus and Horticulture
Problem DescriptionThese days Lotus is interested in cultivating potted plants, so she wants to build a greenhouse to meet her research desires.Lotus placed all of the n pots in the new gree原创 2017-03-19 21:17:29 · 445 阅读 · 0 评论 -
codeforces #378C(733.C) Epidemic in Monstropolis
There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.Soon, monsters became hungry and be原创 2017-05-20 19:30:30 · 411 阅读 · 0 评论 -
2017多校训练Contest2: 1001 Captain is coding hdu6045
Problem DescriptionDerek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.This summer holiday,they both participate in the summer camp of Borussia Dortmund.During the summer原创 2017-08-16 15:42:06 · 323 阅读 · 0 评论 -
2016多校训练Contest10: 1003 Captain is coding hdu5859
Problem DescriptionTo improve players’ coding skill, FJ collects a variety of problems and order the players to solve them. In order to ensure they can complete the task, FJ divides the problems i原创 2016-08-19 19:06:56 · 514 阅读 · 0 评论 -
2016多校训练Contest5: 1003 Divide the Sequence hdu5783
Problem DescriptionAlice has a sequence A, She wants to split A into as much as possible continuous subsequences, satisfying that for each subsequence, every its prefix sum is not small than 0.原创 2016-08-02 23:07:53 · 340 阅读 · 0 评论 -
bzoj 1707: [Usaco2007 Nov]tanning分配防晒霜
Description奶牛们计划着去海滩上享受日光浴。为了避免皮肤被阳光灼伤,所有C(1 <= C <= 2500)头奶牛必须在出门之前在身上抹防晒霜。第i头奶牛适合的最小和最 大的SPF值分别为minSPF_i和maxSPF_i(1 <= minSPF_i <= 1,000; minSPF_i <= maxSPF_i <= 1,000)。如果某头奶牛涂的防晒霜的SPF值过小,那么阳光仍然原创 2014-09-02 21:03:51 · 1128 阅读 · 0 评论 -
bzoj 1620: [Usaco2008 Nov]Time Management 时间管理
DescriptionEver the maturing businessman, Farmer John realizes that he must manage his time effectively. He has N jobs conveniently numbered 1..N (1 <= N <= 1,000) to accomplish (like milking th原创 2014-10-24 21:10:34 · 762 阅读 · 0 评论 -
3709: [PA2014]Bohater
Description在一款电脑游戏中,你需要打败n只怪物(从1到n编号)。为了打败第i只怪物,你需要消耗d[i]点生命值,但怪物死后会掉落血药,使你恢复a[i]点生命值。任何时候你的生命值都不能降到0(或0以下)。请问是否存在一种打怪顺序,使得你可以打完这n只怪物而不死掉Input第一行两个整数n,z(1接下来n行,每行两个整数d[i],a[i](0Outpu原创 2014-10-14 20:03:18 · 729 阅读 · 0 评论 -
bzoj 1029: [JSOI2007]建筑抢修
每次为何自己贪心就不能一次原创 2014-09-01 20:11:12 · 1859 阅读 · 0 评论 -
bzoj 3874: [Ahoi2014]宅男计划
Description 【故事背景】自从迷上了拼图,JYY就变成了个彻底的宅男。为了解决温饱问题,JYY不得不依靠叫外卖来维持生计。【问题描述】外卖店一共有N种食物,分别有1到N编号。第i种食物有固定的价钱Pi和保质期Si。第i种食物会在Si天后过期。JYY是不会吃过期食物的。比如JYY如果今天点了一份保质期为1天的食物,那么JYY必须在今天或者明天把这个食物吃掉,原创 2015-02-04 23:12:20 · 2613 阅读 · 0 评论 -
bzoj 1907: 树的路径覆盖
DescriptionInputOutputSample Input171 22 32 44 65 66 7Sample Output3HINTSourcePlay with Tree By Amber自己写了一发贪心WA了。。然后去看题解f[i]表示i为子树的最小路原创 2015-02-23 19:20:58 · 1055 阅读 · 0 评论 -
bzoj 3671: [Noi2014]随机数生成器
DescriptionInput第1行包含5个整数,依次为 x_0,a,b,c,d ,描述小H采用的随机数生成算法所需的随机种子。第2行包含三个整数 N,M,Q ,表示小H希望生成一个1到 N×M 的排列来填入她 N 行 M 列的棋盘,并且小H在初始的 N×M 次交换操作后,又进行了 Q 次额外的交换操作。接下来 Q 行,第 i 行包含两个整数 u_i,v_i,表示第原创 2015-02-28 18:55:45 · 1065 阅读 · 0 评论 -
bzoj 3877: [Ahoi2014]保龄球
Description 【故事背景】JYY很喜欢打保龄球,虽然技术不高,但是还是总想着的高分。这里JYY将向你介绍他所参加的特殊保龄球比赛的规则,然后请你帮他得到尽量多的分数。【问题描述】一场保龄球比赛一共有N个轮次,每一轮都会有10个木瓶放置在木板道的另一端。每一轮中,选手都有两次投球的机会来尝试击倒全部的10个木瓶。对于每一次投球机会,选手投球的得分等于这一次投球所原创 2015-03-01 19:01:43 · 1555 阅读 · 0 评论 -
bzoj 2006: [NOI2010]超级钢琴
Description小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐。 这架超级钢琴可以弹奏出n个音符,编号为1至n。第i个音符的美妙度为Ai,其中Ai可正可负。 一个“超级和弦”由若干个编号连续的音符组成,包含的音符个数不少于L且不多于R。我们定义超级和弦的美妙度为其包含的所有音符的美妙度之和。两个超级和弦被认为是相同的,当且原创 2015-04-15 09:09:54 · 564 阅读 · 0 评论 -
bzoj 4472: [Jsoi2015]salesman
Description某售货员小T要到若干城镇去推销商品,由于该地区是交通不便的山区,任意两个城镇之间都只有唯一的可能经过其它城镇的路线。 小T 可以准确地估计出在每个城镇停留的净收益。这些净收益可能是负数,即推销商品的利润抵不上花费。由于交通不便,小T经过每个城镇都需要停留,在每个城镇的停留次数与在该地的净收益无关,因为很多费用不是计次收取的,而每个城镇对小T的商品需求也原创 2016-04-04 19:08:54 · 1051 阅读 · 0 评论 -
bzoj 4401: 块的计数
Description小Y最近从同学那里听说了一个十分牛B的高级数据结构——块状树。听说这种数据结构能在sqrt(N)的时间内维护树上的各种信息,十分的高效。当然,无聊的小Y对这种事情毫无兴趣,只是对把树分块这个操作感到十分好奇。他想,假如能把一棵树分成几块,使得每个块中的点数都相同该有多优美啊!小Y很想知道,能有几种分割方法使得一棵树变得优美。小Y每次会画出一棵树,但由于手速太快,有时候原创 2016-06-14 21:51:41 · 517 阅读 · 0 评论 -
2016中国大学生程序设计竞赛 - 网络选拔赛 1004 Danganronpa hdu5835
Problem DescriptionChisa Yukizome works as a teacher in the school. She prepares many gifts, which consist of n kinds with a[i] quantities of each kind, for her students and wants to hold a cl原创 2016-08-14 23:05:13 · 522 阅读 · 0 评论 -
bzoj 4069: [Apio2015]巴厘岛的雕塑
Description印尼巴厘岛的公路上有许多的雕塑,我们来关注它的一条主干道。在这条主干道上一共有 N 座雕塑,为方便起见,我们把这些雕塑从 1 到 N 连续地进行标号,其中第 i 座雕塑的年龄是 Yi 年。为了使这条路的环境更加优美,政府想把这些雕塑分成若干组,并通过在组与组之间种上一些树,来吸引更多的游客来巴厘岛。下面是将雕塑分组的规则:这些雕塑必须被分为恰好 X 组,其原创 2016-08-01 15:11:04 · 464 阅读 · 0 评论 -
2016多校训练Contest6: 1010 Windows 10 hdu5802
Problem DescriptionLong long ago, there was an old monk living on the top of a mountain. Recently, our old monk found the operating system of his computer was updating to windows 10 automatically原创 2016-08-04 22:48:42 · 458 阅读 · 0 评论 -
2017多校训练Contest2: 1003 Maximum Sequence hdu6047
Problem DescriptionSteph is extremely obsessed with “sequence problems” that are usually seen on magazines: Given the sequence 11, 23, 30, 35, what is the next number? Steph always finds them too原创 2017-08-16 15:45:17 · 319 阅读 · 0 评论