贪心
文章平均质量分 78
贪心
浪漫些许潦草
这个作者很懒,什么都没留下…
展开
-
poj Radar Installation
Radar Installation题意:求能覆盖所有岛屿的最小雷达数。思路:先对每个岛屿求区间:能覆盖它的所有雷达圆心所构成的区间。然后按照右端点从小到大排序。如果一个岛屿的左端点大于它前一个岛屿的右端点,雷达+1.代码示例:#include#include#includeusing namespace std;struct zxc{ doubl原创 2016-11-18 18:26:50 · 577 阅读 · 0 评论 -
FZU 2203 单纵大法好 (二分+贪心)
单纵大法好Problem Description 人在做,天在看,单纵不怂保平安众娘皆为轮回来,敢教POI进夜战。勿怪战列低智商,航母不是一个样?假摔不虚有损管,大破进击是真相!老S最近喜欢上某个搜集战舰的游戏,这个游戏中很重要的一个内容是能编排自己的战舰,通过出击完成任务来获取资源或新的战舰。大家都说老S是一个“直男”,所以他喜欢把战舰排成一条直线。目前老S正准备完成某个新的任务–“困难级丹麦海原创 2017-06-15 14:46:28 · 437 阅读 · 0 评论 -
hdu 1050 Moving Tables(贪心)
Moving TablesProblem Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north sid原创 2017-07-06 20:08:40 · 359 阅读 · 0 评论 -
poj 2325 Persistent Numbers(高精度除法+贪心)
Persistent NumbersDescriptionThe multiplicative persistence of a number is defined by Neil Sloane (Neil J.A. Sloane in The Persistence of a Number published in Journal of Recreational Mathematics 6, 19原创 2017-07-07 10:48:00 · 747 阅读 · 0 评论 -
hdu 1052 Tian Ji -- The Horse Racing(贪心)
Tian Ji – The Horse RacingProblem Description Here is a famous story in Chinese history.“That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to play horse ra原创 2017-07-07 21:29:16 · 285 阅读 · 0 评论 -
poj 3258 River Hopscotch(二分法,最小值最大化)
River HopscotchDescriptionEvery year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long,原创 2017-07-08 08:42:26 · 607 阅读 · 0 评论 -
poj 2376 Cleaning Shifts(贪心)
Cleaning ShiftsDescriptionFarmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and ha原创 2017-07-08 10:04:12 · 340 阅读 · 0 评论 -
poj Supermarket(贪心)(并查集)(优先队列)
SupermarketDescriptionA supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time unit原创 2017-03-08 21:48:50 · 1051 阅读 · 0 评论 -
CodeForces - 758D Ability To Convert(贪心)
Ability To ConvertAlexander is learning how to convert numbers from the decimal system to any other, however, he doesn’t know English letters, so he writes any number only as a decimal number, it means原创 2017-07-29 23:10:13 · 466 阅读 · 0 评论 -
poj 2393 Yogurt factory(贪心)
Yogurt factoryDescriptionThe cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, the price of milk and labor will fluctuate weekly such原创 2017-07-08 10:49:15 · 415 阅读 · 0 评论 -
hdu 1789 Doing Homework again(贪心)
Doing Homework againProblem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If原创 2017-07-10 08:22:24 · 331 阅读 · 0 评论 -
nyoj 1170 最大的数(贪心)
最大的数描述 小明和小红在打赌说自己数学学的好,于是小花就给他们出题了,考考他们谁NB,题目是这样的给你N个数 在这n个数之间添加N-1个*或+,使结果最大,但不可以打乱原顺序,请得出这个结果 如 1 3 5 结果是(1+3)*5=20;最大 可以添加若干个括号,但一定要保证配对,但是每两个数之间只可能有一个*或+ 数列最前和最后不应有+或乘 小明想赢小红但是他比较笨,请你帮帮他原创 2017-07-10 09:13:44 · 445 阅读 · 0 评论 -
hdu 6034 Balala Power!(贪心)( 2017 Multi-University Training Contest - Team 1 )(无耻之sort)
Balala Power!Problem DescriptionTalented Mr.Tang has n strings consisting of only lower case characters. He wants to charge them with Balala Power (he could change each character ranged from a to z int原创 2017-07-26 09:48:56 · 668 阅读 · 2 评论 -
hdu 6180 Schedule(贪心)
题目链接:Schedule题意:已知一些任务的开始时间和结束时间,一台机器同时只能运行一个任务(机器中间不关闭运行),求在使用最少机器工作的前提下机器工作的最短时间思路:将开始时间标记为1,结束时间标记为-1。 按照时间大小对这2n2n个时间从小到大排序,然后遍历计算前缀和,当前缀和每次增加1的时候,说明需要新开一台机器才能运行,这样可以寻找到每台机器的开始时间。同理,逆序遍历计算前缀和,可以记录原创 2017-08-27 15:57:40 · 529 阅读 · 0 评论 -
hdu The Frog's Games(二分枚举)
The Frog's Games原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4004题目大意:长为L的河流,中间有n个石头,告诉你石头的位置,青蛙的跳跃能力至少为多少时最终跳m次能跳过终点思路:因为青蛙的跳跃能力越强需要的次数就越少,因此青蛙的跳跃能力有单调性,所以二分枚举青蛙的跳跃能力,再判断在这个能力下是否能够跳过去。这个用原创 2016-11-28 16:55:45 · 546 阅读 · 0 评论 -
CodeForces - 792C Divide by Three(思路)(分类讨论)
Divide by ThreeA positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you w原创 2017-04-12 12:33:42 · 586 阅读 · 0 评论 -
hdu 3466 Proud Merchants(贪心+DP)
Proud MerchantsProblem Description Recently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country a原创 2017-03-24 10:31:12 · 691 阅读 · 2 评论 -
nyoj 独木舟上的旅行
独木舟上的旅行描述 进行一次独木舟的旅行活动,独木舟可以在港口租到,并且之间没有区别。一条独木舟最多只能乘坐两个人,且乘客的总重量不能超过独木舟的最大承载量。我们要尽量减少这次活动中的花销,所以要找出可以安置所有旅客的最少的独木舟条数。现在请写一个程序,读入独木舟的最大承载量、旅客数目和每位旅客的重量。根据给出的规则,计算要安置所有旅客必须的最少的独木舟条数,并输出结果。输入第一行原创 2016-10-28 19:20:42 · 547 阅读 · 0 评论 -
nyoj +-字符串
+-字符串描述 Shiva得到了两个只有加号和减号的字符串,字串长度相同。Shiva一次可以把一个加号和它相邻的减号交换。他想知道最少需要多少次操作才能把第一个字符串变换成第二个字符串。你现在要去帮助他完成那个这个问题。输入多组测试数据每组数据有两行,每行包含一个由”+”和”-“最成的字符串。每个子符串长度不超过5000。输出仅一个整数,输出最少需要操作的次数。如果答案不存在,转载 2016-10-31 18:33:47 · 536 阅读 · 0 评论 -
nyoj 田忌赛马
田忌赛马题目大意:第一行给出n表示有n场比赛,以下两行分别给出n个数,分别表示田忌和齐王n匹马的速度,赢家从输者手中获得200钱,求田忌最多能赢多少钱。思路:1.先把两者的马按速度从大到小排序2.从最大的马开始比较,若出现齐王的马比田忌的马快,先暂停。3.将此时齐王最快的马和田忌最慢的马比赛,田忌输掉一局,记录下来,并且这两匹马退出比赛,马的数量减1。4.返回2,继续比较。原创 2016-11-15 15:26:10 · 861 阅读 · 0 评论 -
Codeforces Round #387 (Div. 2) Winter Is Coming(贪心)
Winter Is Coming原题链接:http://codeforces.com/problemset/problem/747/DThe winter in Berland lasts n days. For each day we know the forecast for the average air temperature that day.原创 2016-12-20 12:34:34 · 776 阅读 · 0 评论 -
nyoj 最少拦截系统
最少拦截系统某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一转载 2016-11-15 15:05:10 · 424 阅读 · 0 评论 -
nyoj 寻找最大数
寻找最大数描述 请在整数 n 中删除m个数字, 使得余下的数字按原次序组成的新数最大,比如当n=92081346718538,m=10时,则新的最大数是9888 输入第一行输入一个正整数T,表示有T组测试数据每组测试数据占一行,每行有两个数n,m(n可能是一个很大的整数,但其位数不超过100位,并且保证数据首位非0,m小于整数n的位数)输出每组测试数据的输出占一行,转载 2016-11-01 20:13:35 · 605 阅读 · 0 评论 -
nyoj 会场安排问题
会场安排问题描述 学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办。小刘的工作就是安排学校小礼堂的活动,每个时间最多安排一个活动。现在小刘有一些活动计划的时间表,他想尽可能的安排更多的活动,请问他该如何安排。输入第一行是一个整型数m(m每组测试数据的第一行是一个整数n(1随后的n行,每行有两个正整数Bi,Ei(0输出对于每一组输转载 2016-11-03 09:24:29 · 424 阅读 · 0 评论 -
nyoj 阶乘之和
阶乘之和描述 给你一个非负数整数n,判断n是不是一些数(这些数不允许重复使用,且为正数)的阶乘之和,如9=1!+2!+3!,如果是,则输出Yes,否则输出No;输入第一行有一个整数0每组测试数据有一个正整数n输出如果符合条件,输出Yes,否则输出No;样例输入2910样例输出YesNo方法一:#includeint main(){ in原创 2016-11-08 07:50:29 · 442 阅读 · 0 评论 -
poj Best Cow Line
Best Cow Line题意:就是说给你一系列字母, 要你取出字典序最小的字符串,每次只能从最上面或者最下面进行取,每次从上和从下选择最小的,若相等则向中间搜索,找到较小的。注意:1.先吸收空格,再输入字符;2.当左右两边相等时,继续向中间搜索;3.每80字符之后要换行。代码示例:#include#includechar a[2005],b[2原创 2016-11-17 21:21:24 · 498 阅读 · 0 评论 -
【CodeForces】500B - New Year Permutation(Floyd)(贪心)
New Year PermutationUser ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prett原创 2017-03-01 20:08:48 · 612 阅读 · 0 评论 -
CodeForces - 731C Socks(并查集)(贪心)
SocksArseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Ars原创 2017-03-12 15:59:51 · 839 阅读 · 0 评论 -
ZOJ 3715 Kindergarten Election(枚举+贪心)
Kindergarten ElectionAt the beginning of the semester in kindergarten, the n little kids (indexed from 1 to n, for convenience) in class need to elect their new leader.The ith kid will vote for his bes原创 2017-04-07 21:55:10 · 620 阅读 · 0 评论 -
ZOJ 2315 New Year Bonus Grant(贪心)
New Year Bonus GrantAll programmers of Mocrosoft software company are organized in a strict subordination hierarchy. Every programmer has exactly one chief, except Bill Hates who is also the head of th原创 2017-04-18 21:07:39 · 446 阅读 · 0 评论 -
CodeForces - 853A Planning(贪心)
Planning题目链接:Planning题意:飞机场原定计划从第一分钟开始每分钟起飞一架飞机,但是由于某些原因导致前k分钟无法起飞飞机。给出每架飞机每延误一分钟的损失costi{cost_i},问所有飞机都起飞后的最小损失为多少思路:对于k+1到k+n的每一时刻,每次把将要延误的所有飞机加入队列中,然后取出cost最大的,让其在这个时刻起飞,最后所得的答案就是最小的损失代码:#include<st原创 2017-09-07 09:52:24 · 1017 阅读 · 0 评论