贪心大法
so_so_y
start to record bugs <- so hard so brave
展开
-
HDU 6034 Balala Power!(多校1)
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 into each number原创 2017-07-29 21:03:04 · 207 阅读 · 0 评论 -
51nod 1435 位数阶乘(贪心)
题目描述X是一个n位数的正整数 (x=a0a1…an−1) 现在定义 F(x)=∏i=0n−1(ai!) , 比如F(135)=1!*3!*5!=720. 我们给定一个n位数的整数X(至少有一位数大于1,X中可能有前导0), 然后我们去找一个正整数(s)符合以下条件: 1.这个数尽可能大, 2.这个数中不能含有数字0或1。 3.F(s)=F(x)Input每个测试数...原创 2018-04-13 21:42:06 · 210 阅读 · 0 评论 -
51nod 1420 数袋鼠好有趣 (贪心)
Description有n只袋鼠。每只袋鼠的大小用一个整数表示。一只小袋鼠能装进一只大袋鼠的条件是,大袋鼠的大小至少是小袋鼠的两倍。 每只大袋鼠最多可以装一只袋鼠。小袋鼠被装进大袋鼠之后就不能再装其它的袋鼠了。 小袋鼠被装进大袋鼠之后就不能被我们看见了。请找出一个装袋鼠的方案,使得被看见的袋鼠最少。Input单组测试数据。 第一行包含一个整数n(1≤n≤5*10^5)。 接下来...原创 2018-02-16 23:17:32 · 265 阅读 · 0 评论 -
51nod 1449 砝码称重(进制思想+贪心)
Description现在有好多种砝码,他们的重量是 w0,w1,w2,… 每种各一个。问用这些砝码能不能表示一个重量为m的东西。 样例解释:可以将重物和3放到一个托盘中,9和1放到另外一个托盘中。Input单组测试数据。 第一行有两个整数w,m (2 ≤ w ≤ 10^9, 1 ≤ m ≤ 10^9)。Output如果能,输出YES,否则输出NO。Input示例...原创 2018-02-16 21:53:57 · 430 阅读 · 0 评论 -
FZU 2219 StarCraft(贪心+优先队列)
Problem DescriptionZB loves playing StarCraft and he likes Zerg most!One day, when ZB was playing SC2, he came up with an idea:He wants to change the queen’s ability, the queen’s new ability is ...原创 2018-02-15 20:22:21 · 379 阅读 · 0 评论 -
51nod 1117 聪明的木匠 (贪心+优先队列)
Description一位老木匠需要将一根长的木棒切成N段。每段的长度分别为L1,L2,……,LN(1 <= L1,L2,…,LN <= 1000,且均为整数)个长度单位。我们认为切割时仅在整数点处切且没有木材损失。 木匠发现,每一次切割花费的体力与该木棒的长度成正比,不妨设切割长度为1的木棒花费1单位体力。例如:若N=3,L1 = 3,L2 = 4,L3 = 5,则木棒原长为1...原创 2018-02-15 19:17:34 · 386 阅读 · 0 评论 -
贪心四部曲
NYOJ71 独木舟上的旅行问题描述 n个人乘船,要求在独木舟最大承载量w内求出需安置的最少的独木舟数,限制每条船最多乘坐两人。 问题分析 在整体中首先需要考虑体重最轻的一个人,如果没有人可以与他一起同坐一艘船,则必须每个人独自乘坐;不然根据贪心的策略,应在能 和他一起乘船的人中选择最重的那一个人与他一起乘船。代码实现#include <iostream>...原创 2017-01-27 18:03:42 · 517 阅读 · 1 评论 -
51nod 1246 罐子和硬币(贪心)
Description有n个罐子,有k个硬币,每个罐子可以容纳任意数量的硬币。罐子是不透明的,你可以把这k个硬币任意分配到罐子里。然后罐子被打乱顺序,你从外表无法区别罐子。最后罐子被编上号1-n。每次你可以询问某个罐子,如果该罐子里有硬币,则你可以得到1个(但你不知道该罐子中还有多少硬币),如果该罐子是空的,你得不到任何硬币,但会消耗1次询问的机会。你最终要得到至少c枚硬币(c <= k),问题是给原创 2017-11-03 15:45:18 · 312 阅读 · 0 评论 -
Codeforces Round #437 Div. 2 E. Buy Low Sell High
DescriptionYou can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each da原创 2017-10-02 22:19:10 · 339 阅读 · 0 评论 -
Codeforces Round #436 (Div. 2) D. Make a Permutation!
DescriptionIvan has an array consisting of n elements. Each of the elements is an integer from 1 to n.Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (r原创 2017-10-02 21:30:53 · 186 阅读 · 0 评论 -
Codeforces Round #437 Div. 2 C. Ordering Pizza
DescriptionIt’s another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let’s just pretend for the sake of the原创 2017-10-02 22:15:26 · 642 阅读 · 0 评论 -
HDU 6047 Maximum Sequence(多校2)
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 easy原创 2017-07-28 16:20:29 · 246 阅读 · 0 评论 -
山东省第八届ACM省赛 CF(贪心+01背包)
Problem Description LYD loves codeforces since there are many Russian contests. In an contest lasting for T minutes there are n problems, and for the ith problem you can get ai−di∗ti points, where ...原创 2018-04-24 11:40:58 · 288 阅读 · 0 评论