题目链接:http://codeforces.com/gym/100187/problem/A 题解: 光题意就想了很久:在最坏情况下的最小兔子数.其实就是至少用几只兔子就一定能找出仙药(答案存在的话).再注意一下特殊情况就可以了, 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <string> #include…
A. Potion of Immortality Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/A Description The world famous scientist Innokentiy has just synthesized the potion of immortality. Unfortunately, he put the flask with th…
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description Noura Boubou is a Syrian volunteer at ACM ACPC (Arab Collegiate Programming Contest) since 2011. She graduated from Tishreen Un…
根据兔子试药情况可以缩小范围,如果死了,不在试过的药里面,如果活着,在试过的药里. 最糟的情况: 两个原则 1.能确定魔药所在的范围的尽量大,2.死得兔子尽量多. 如果当前不知道情况的药n为k的二倍以上,那么基于上面两个原则,试过药的兔子肯定会死. 没死:范围k,损失的兔子0 死了:范围n-k,损失的兔子1 (n>2*k) (符合两个原则) 设r=n%k,经过上述过程,损失了n/k-1只兔子,转移到了当前状态范围w = k+r, 1.r == 0 那么可以补充一个毒药,变成w=k+1,根据鸽巢原…
Intervals 题目连接: http://codeforces.com/gym/100231/attachments Description 给你n个区间,告诉你每个区间内都有ci个数 然后你需要找一个最小的点集,使得满足这n个区间的条件 Input n 然后li,ri,ci Output 输出最小点集大小 Sample Input 5 3 7 3 8 10 3 6 8 1 1 3 1 10 11 1 Sample Output 6 Hint 题意 题解: 线段树+二分+贪心 首先我们贪心一…
F. Doomsday Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/F Description Doomsday comes in t units of time. In anticipation of such a significant event n people prepared m vaults in which, as they think, it will…
题目链接:http://codeforces.com/gym/101981/attachments There are n heroes and m monsters living in an island. The monsters became very vicious these days,so the heroes decided to diminish the monsters in the island. However, the i-th hero can only kill on…
Problem H. Hell on the MarketsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86821#problem/H Description Most financial institutions had become insolvent during financial crisis and went bankrupt or…
<题目链接> 题目大意: 一家公司想让n个人给他们的产品评论,所以依次去找这n个人,第i个人会评论当且仅当已经有ai个人评论或他确实对这个产品感兴趣,但是这n个人都不对这个产品感兴趣,问这个公司至少要说服几个人对该产品该兴趣才能至少收到m个人的评论. 解题分析: 直接二分答案,然后按顺序进行判断,如果ai大于当前评论的人就说服该人,这里用到了贪心的思想(本题的关键),因为说服该人能够提供评论数的贡献,所以越早做贡献能够带来更多的贡献,然后根据评论的人数与m的比较来控制二分答案的方向. #inc…
原题链接 题意:俄罗斯套娃,给出一个初始状态和终止状态,问至少需要多少步操作才能实现状态转化 贪心做法如果完全拆掉再重装,答案是p[i]和q[i]中不为0的值的个数.现在要求寻找最小步数,显然要减去一些多余的步数.如果初始的一些链的前端是终止的某一条链的连续的一部分,那么这条链就不用被拆开再连上,这样每一个长度为x的链对答案的贡献就是-2*(x-1),对每条链进行同样的操作之后就是答案 #include <iostream> #include<cstdio> #include<…