hdu 2654 Be a hero】的更多相关文章

()Become A Hero Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 295    Accepted Submission(s): 83 Problem Description Lemon wants to be a hero since he was a child. Recently he is reading a boo…
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…
The Romantic Hero 题目链接: http://acm.hust.edu.cn/vjudge/contest/121349#problem/E 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 b…
题目大意:给你n个数字,然后分成两份,前边的一份里面的元素进行异或,后面的一份里面的元素进行与.分的时候依照给的先后数序取数,后面的里面的全部的元素的下标一定比前面的大.问你有多上种放元素的方法能够使得前面异或的值和后面与的值相等. dp[x][y] 表示走到第x步,得到y这个数字一共同拥有多少种方法. 可是须要注意这里得分一下,不能直接用dp数组存种数,你须要分一下从上一层过来的次数,和这一层自己能够到达的次数.然后取和的时候前后两个集合的种数进行乘法,注意边乘边取余. 顺便给一组数据: 4…
Problem DescriptionYou are the hero who saved your country. As promised, the king will give you some cities of the country, and you can choose which ones to own!But don't get too excited. The cities you take should NOT be reachable from the capital -…
The Romantic Hero Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1675    Accepted Submission(s): 705 Problem Description There is an old country and the king fell in love with a devil. The de…
Become A Hero Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 210    Accepted Submission(s): 57 Problem Description Lemon wants to be a hero since he was a child. Recently he is reading a book…
题目链接 题意 :给你一个数列,让你从中挑选一些数组成集合S,挑另外一些数组成集合T,要求是S中的每一个数在原序列中的下标要小于T中每一个数在原序列中下标.S中所有数按位异或后的值要与T中所有的数按位与的值相同,问能找出多少符合要求的组合. 思路 :比赛的时候有点没有头绪,后来二师兄想出了状态转移方程,YN又改了很多细节,最后才A的.总之是个别扭的DP..... 一开始是 _xor[i][j^a[i]] += _xor[i-1][j] :j 的下一个状态 就是异或上a[i],这个数组所代表的意思…
题目链接 题意:给一个数组a,从中选择一些元素,构成两个数组s, t,使s数组里的所有元素异或 等于 t数组里的所有元素 位于,求有多少种构成方式.要求s数组里 的所有的元素的下标 小于 t数组里的所有的元素的下标. 分析:比赛的时候,刚开始脑子很乱,后来想了一下思路也敲了,发现自己的程序结果不对 自己一点一点计算后发现自己的程序有一部分计算重复了,其实还是dp的思路不够清晰. d[i][j]代表第i个数 新产生的结果为数字 j 的个数. AC代码: #include <iostream> #…
https://vjudge.net/problem/HDU-4901 题意 给n个数,构造两个集合,使第一个集合的异或和等于第二个集合的相与和,且要求第一个集合的元素下标都小于第二个集合的元素下标.问方案数 分析 dp来做.dp1[i][j]表示0~i的元素异或和为j的个数.dp2[i][j]表示i~n-1的元素相与和为j的个数.注意状态转移时要同时计算第i个数参与或不参与的情况,且dp1的第一维不能取到n-1,类似的,dp2的第一维不能取0.统计最终答案时需要合并,那么怎么才能防止重复呢?这…
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…
传送阵: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的方案数,但是这样…
题目地址:HDU 4901 这题没想到最后竟然可以做出来.. .. 这题用了两次DP,先从前往后求一次异或的.再从后往前求一次与运算的. 各自是 1:求异或的时候,定义二维数组huo[1000][1024],前者指第几位,后者是哈希的思想.若huo[x][y]=2则表示最右边的数为第x位时,异或值为y的出现了两次,须要再定义一个hash数组.来保存前面出现的全部情况.再找有多少位的时候,用hash数组中出现的全部的值与当前的第x位的数字进行异或. 2:求与的时候,定义二维数组yu[1000][1…
Being a Hero Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1211    Accepted Submission(s): 381 Special Judge Problem Description You are the hero who saved your country. As promised, the ki…
这道题是道算是一道很简单的贪心题了,但是要注意排序的依据,这道题是按照dps/hp的从大到小排序的,然后计算总的sumhp即可. #include"iostream" #include"stdio.h" #include"cmath" #include"string.h" #include"algorithm" #define mx 105 using namespace std; struct enemy…
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…
[题意]:给出n个点,m条边,边分为两种,一种是A公司的,一种是B公司的.边上有权值,问用n-1条边把n个点连起来的最小费用是多少,其中A公司的边刚好有k条.题目保证有解. 思路:我们发现,如果我们给白边增加权值,做最小生成树,由于白边权值增大,导致不容易选白边.记f(x)为给白边增加x权值,做最小生成树后,选白边的数量,可以发现,f(x)随x增大而减小.所以可以二分x 首先,直接做MST的话白色边的数量是无法估计的.可能比要求的多,也可能更少 所以考虑怎样调整白色边的数量 通过这个思路,可以想…
题意:给定你有 n 个敌人,你的伤害是 1,给出每个敌人的伤害,和敌人的血量,每一回合你可以攻击一个敌人,并且所有敌人都会攻击你,除非它已经死了,问你最少要多少要消耗多少血量. 析:一个很明显的贪心问题,按照 攻击 / 血量进行排序,然后一个一个的消灭就好了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #inc…
题意:给你一个基因序列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…
题意: 在一个有向图中,有n个点,m条边$n \le 1000 \And \And  m \le 100000$ 每条边有一个破坏的花费,有些点可以被选择并获得对应的金币. 假设一个可以选的点是$x$,你只有破坏了从1号点到$x$的路,才可以得到$x$对应的金币. 思路: 点和边的区别在于,你放弃一个点得到0,选择一个点得到val.你放弃选择一条边得到0,选择一条边得到 - val. 那么我们先把每个点的权值加到ans中,最够减去这个图的最小割即可. 由于要输出破坏边的方案,所以要dfs染色,又…
http://acm.hdu.edu.cn/showproblem.php?pid=1026 题意:给出一个迷宫,求出到终点的最短时间路径. 这道题目在迷宫上有怪物,不同HP的怪物会损耗不同的时间,这个时候可以用优先队列,每次让时间最短的出队列.由于最后还需要输出路径,所以需要设置一个数组来保存路径. #include<iostream> #include<queue> #include<cstring> using namespace std; + ; struct…
2014多校4的1005 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4901 The Romantic Hero Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 393    Accepted Submission(s): 150 Problem Description There i…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1026 题目大意:最短时间内出迷宫.迷宫里要杀怪,每个怪有一定HP,也就是说要耗一定时.输出方案. 解题思路: 要是没有输出方案,就是一个简单粗暴的BFS. 一开始解决输出方案问题时,简单粗暴地在每次状态里加个vector,然后连带vector一起转移. 结果vector的push_back实在太慢,无论怎么优化都是T. 于是参考了ACMan同学的方案,path[X][Y]记录下父亲点. 最后输出的…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1026 Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166's castle. The castle is a large labyrinth.…
http://acm.hdu.edu.cn/showproblem.php?pid=1026 记录bfs路径,用一个数组记录next前驱的方向,然后递归的时候减回去即可 #include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std ; const int INF=0xfffffff; int n,m; ][]; struct node…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1026 Ignatius and the Princess I Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166's castle. The castle…
http://acm.hdu.edu.cn/showproblem.php?pid=1155 Bungee Jumping Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 811    Accepted Submission(s): 349 Problem Description Once again, James Bond is fle…
Ignatius and the Princess IV Time Limit:1000MS     Memory Limit:32767KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1029 Appoint description:  jehad  (2014-05-27) gscsdlz  (2015-04-14) System Crawler  (2015-09-05) Description "OK…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
Problem DescriptionMost of us know that in the game called DotA(Defense of the Ancient), Pudge is a strong hero in the first period of the game. When the game goes to end however, Pudge is not a strong hero any more.So Pudge’s teammates give him a ne…