此题的大意就是要制作一条项链,这个项链必须用k块石头来制作,且重量不能超过W,问所能制作项链的最大价值。此题数据很水,DFS完全暴力就能过。
1 #include 2 #include 3 #include 4 #define MAX(A,B) (A>B?A:B) 5 int n, k,
W;//n...
分类:
其他好文 时间:
2014-06-11 12:02:02
阅读次数:
144
http://acm.hdu.edu.cn/showproblem.php?pid=1599#include #include #include
#include #include #include #include #include #include #include #include using...
分类:
其他好文 时间:
2014-06-11 07:27:25
阅读次数:
243
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=151For each list
of words, output a line with each word reversed without changing the or...
分类:
其他好文 时间:
2014-06-10 00:14:19
阅读次数:
300
HDU 4324 Triangle LOVE (拓扑排序)
题目大意:
T组测试数据,每组数据一个n表示n个人,接下n*n的矩阵表示这些人之间的关系,输入一定满足若A不喜欢B则B一定喜欢A,且不会出现A和B相互喜欢的情况,问你这些人中是否存在三角恋。
解题思路:
拓扑排序思想很简单,就是找入度为0的点,放入队列,用队列来实现。
拓扑排序后判断是否有环存在,有环必然存在是三角恋。
证明:
假设存在一个n元环
首先,...
分类:
其他好文 时间:
2014-06-08 18:31:38
阅读次数:
241
下面说说split函数的用法
def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')#split('.',1) use '.' split one time
return words
def sort_words(wo...
分类:
编程语言 时间:
2014-06-08 18:19:21
阅读次数:
336
本题有两个考点:
1 求逆序数的性质
计算逆序数的公式, 一个数arr[i]从前面放到后面,必然会有n-arr[i]-1个数比这个大,那么就有n-arr[i]-1个逆序数增加,同时因为前面少了个arr[i]数,那么就必然有arr[i]个(加上零)数比起小的数失去一个逆序数,总共失去arr[i]个逆序数,所以新的逆序数为增加了n-arr[i]-1-arr[i]个逆序数(当然有可能是减小了,视ar...
分类:
其他好文 时间:
2014-06-08 15:52:20
阅读次数:
275
Problem Description
Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers:
1. Emergenc...
分类:
其他好文 时间:
2014-06-08 10:31:22
阅读次数:
234
要询问一个数列的某区间的最大值,其中会更新数据。
这样的题目使用树状数组是可以的,但是因为要牵涉到区间操作,故此还是线段树比较好点。
不过使用树状数组也是可以的,就是查询的时候麻烦点,注意计算,不要超出区间了。
看下面的query函数,这是主要的难点函数,其中的-1操作和这个判断r - lowbit(r) >= l,都很蛋疼,一不小心就会出错。
#include
#inc...
分类:
其他好文 时间:
2014-06-08 09:02:49
阅读次数:
345
QueuingTime Limit: 10000/5000 MS
(Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s):
2483Accepted Submission(s): 1169Problem De...
分类:
其他好文 时间:
2014-06-08 00:33:08
阅读次数:
403
Problem Description
Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).
Input
输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是...
分类:
其他好文 时间:
2014-06-07 12:25:46
阅读次数:
329