求树的最大路径和(Binary Tree Maximum Path Sum)...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 18:25:41   
                                阅读次数:
235
                             
                    
                        
                            
                            
                                http://acm.hdu.edu.cn/showproblem.php?pid=3790
有两个条件:距离和花费。首先要求距离最短,距离相等的条件下花费最小。
dijkstra,只是在判断条件时多考虑了花费。
注意重边。
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#incl...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 15:14:22   
                                阅读次数:
235
                             
                    
                        
                            
                            
                                题目:
     链接:点击打开链接
思路:
    搜索入门题。
代码:
#include
#include
#include
using namespace std;
int m,n;
char s[110][110];
int vis[110][110];
void dfs(int x,int y)
{
    if(s[x][y] == '*' || vis[x][y])
 ...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 10:46:12   
                                阅读次数:
277
                             
                    
                        
                            
                            
                                【题目】
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, only n...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 10:22:34   
                                阅读次数:
367
                             
                    
                        
                            
                            
                                题目链接:hdu 4811 Ball
题目大意:有三种颜色的球若干,每次向桌子上放一个球,保证是一条序列,每次放球的得分为当前放入序列的球的前面有多少种不同的颜色a,后面的有多少种不同的颜色b,a+b。问说给定球的数量后,最大得分为多少。
解题思路:因为放球顺序是自己定的,所以我们可以尽量早得构造一个序列,使得后面放入球的得分均保持在峰值。那么求峰值就要根据球的数量来决定。我们叫得分为...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 10:01:02   
                                阅读次数:
192
                             
                    
                        
                            
                            
                                题目链接:hdu 4810 Wall Painting
题目大意:有以为画家,有n种颜料,给出n种颜料的值。然后在1~n天中,他每天都会选择相应天数的颜料数进行混合,形成新的一种颜料。比如说第2天,他会选择任意两种的颜料混合,得到新的一种颜料(所选的颜料的值全部取亦或后的到的数即为新颜料的值)
然后对应输出每一天有可能合成颜料值的总和。
解题思路:因为要考虑到所有情况,所以暴力枚举选...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 07:47:33   
                                阅读次数:
234
                             
                    
                        
                            
                            
                                题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4648
Magic Pen 6
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1857    Accepted Submiss...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 04:56:14   
                                阅读次数:
317
                             
                    
                        
                            
                            
                                题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4810
思路:先把每个数字按位分离出来,存放1的个数,那么每位0的个数为n - 1的个数,然后利用组合数学和异或的原理,枚举奇数个1的情况,然后利用乘法和加法计数原理累加出来的就是该位的答案,最后乘上改为对应的数值最后加起来就是答案
代码:
#include 
#include 
const _...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 04:30:41   
                                阅读次数:
257
                             
                    
                        
                            
                            
                                题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4662
MU Puzzle
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1296    Accepted Submissio...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 04:16:16   
                                阅读次数:
407
                             
                    
                        
                            
                            
                                题目:
    链接:点击打开链接
算法:
    二维的完全背包;
思路:
    状态转移方程:dp[j][m] = max(dp[j][m],dp[j-b[i]][m-1]+a[i]);表示用j的忍耐度杀死m个怪兽能够得到的最大的经验值。
代码:
#include
#include
#include
using namespace std;
int dp[110][110];...
                            
                            
                                分类:
其他好文   时间:
2014-05-18 03:05:42   
                                阅读次数:
338