hdu 4310 Hero】的更多相关文章

A - Hero Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4310 Description When playing DotA with god-like rivals and pig-like team members, you have to face an embarrassing situation: All your t…
这道题是道算是一道很简单的贪心题了,但是要注意排序的依据,这道题是按照dps/hp的从大到小排序的,然后计算总的sumhp即可. #include"iostream" #include"stdio.h" #include"cmath" #include"string.h" #include"algorithm" #define mx 105 using namespace std; struct enemy…
题意:给定你有 n 个敌人,你的伤害是 1,给出每个敌人的伤害,和敌人的血量,每一回合你可以攻击一个敌人,并且所有敌人都会攻击你,除非它已经死了,问你最少要多少要消耗多少血量. 析:一个很明显的贪心问题,按照 攻击 / 血量进行排序,然后一个一个的消灭就好了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #inc…
传送阵:http://acm.hdu.edu.cn/showproblem.php?pid=4899 题目大意:给定一个DNA序列,求有多少长度为m的序列与该序列的最长公共子序列长度为0,1...|S|; 分析:我们可以考虑对于求两个串的最长公共子序列的dp:f[i,j]代表第一个串到了i,第二个串到了j的最长公共子序列.对于两个串来说,如果数组f[i]是完全一样的,则它们对后面的影响也是完全一样的,所以我们可以设2维状态:F[i,j]代表我们当前以及到了i,f[i]的状态为j的方案数,但是这样…
题意 在游戏中你的dps为1但是hp无限 给出n个敌人的dps与hp 你一秒能打掉一个敌人你的dps的hp 当你输出的时候 所有活着的敌人都会打你 求杀死所有敌人时你掉的最少hp 一开始想错了 排序的时候先处理了dps更高的 然后wa 即使在游戏中这也是很傻的.. 应该处理dps/hp更高的 如果放在游戏里讲应该是先杀输出能力高的... 如果直接return a.dps/a.hp>b.dps/b.hp会出现小数 所以用 return a.dps*b.hp>b.dps*a.hp #include…
Problem Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can’t refus…
题意:给你一个基因序列s(只有A,T,C,G四个字符,假设长度为n),问长度为m的基因序列s1中与给定的基因序列LCS是0,1......n的有多少个? 思路:最直接的方法是暴力枚举长度为m的串,然后再用求LCS的dp.当然我们可以在枚举的时候同时进行dp,但是复杂的仍然为O(4 ^ m).我们可以观察求LCS 的状态转移方程:dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) 若s[i] == s1[j] dp[i][j] = max(dp[i - 1][j…
贪心,注意排序条件. #include <iostream> #include <cstdio> #include <algorithm> using namespace std; const int N=25; struct En{ int DSP,HP; }E[N]; bool cmp(En a,En b){ if(a.DSP*1.0/a.HP>b.DSP*1.0/b.HP) return true; return false; } int main(){ i…
2017-08-26  15:25:22 writer:pprp 题意描述: • 1 VS n对战,回合制(你打他们一下,需要受到他们所有存活人的攻击)• 你的血量无上限,攻击力为1• 对手血量及攻击力给定• 消灭所有敌人掉最少的血量• n ≤ 20 贪心的去做,应该优先解决那些攻击力高血量低的敌人,所以应该按照 攻击力/血量 降序排列然后处理就好了 代码如下: /* @theme:hdu 4310 @writer:pprp @declare:简单的贪心算法 将攻击力/血量最高的敌人先进攻下来就…
The Romantic Hero Time Limit: 3000MS   Memory Limit: 131072KB   64bit IO Format: %I64d & %I64u Description 开头背景介绍无用 There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the k…