上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 51 下一页
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2079题意:中文。。。mark:母函数。代码: 1 # include <stdio.h> 2 # include <string.h> 3 4 5 int dp[10][45] ; 6 7 8 int main () 9 {10 int T, n, i, j, k, kk ;11 int a, b ;12 scanf ("%d", &T) ;13 while (T--)14 {15 scanf ("%d%d", &n, & 阅读全文
posted @ 2012-04-11 04:01 Seraph2012 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1075题意:在输入的字符串里找词典中的进行替换。mark:诚然,我很讨厌STL,但是这题要是不用STL的话简直太恶心了。最后非常慢。。。将近TLE。代码: 1 # include <iostream> 2 # include <string> 3 # include <map> 4 # include <stdio.h> 5 6 7 using namespace std ; 8 char s[3010] ; 9 10 11 int main ()12 { 阅读全文
posted @ 2012-04-11 03:53 Seraph2012 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1071题意:按图,给出p1,p2,p3的坐标,计算阴影部分面积。mark:就是求公式咯。设y = ax^2 + bx + c。用(x1,y1),(x2,y2)相减再联合顶点坐标(-b/2a, c-b^2/4a)可以轻易求出a,b,c的值。之后算积分就可以了。注意还要减去直线和x轴所夹梯形的面积。代码: 1 # include <stdio.h> 2 # include <math.h> 3 4 5 double fun(double a, double b, double c, 阅读全文
posted @ 2012-04-11 03:29 Seraph2012 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1677题意:俄罗斯套娃是一种有宽w和高h两种属性的玩具。当wi < wj && hi < hj的时候,套娃i能被套在套娃j里。现在给出m个套娃的宽和高,问最少能套出几个套娃。mark:首先按宽度从大到小排序,得到结果以后按高度求最长非降子序列(LIS)。这题和导弹拦截系统问题一样,是经典dp。一开始偷懒写了贪心结果TLE了。代码: 1 # include <stdio.h> 2 # include <stdlib.h> 3 # include < 阅读全文
posted @ 2012-04-11 02:42 Seraph2012 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1671题意:给堆电话号码(数字,长度不大于10),如果有一个号码是另一个号码的前缀就NO,否则YES。mark:trie树来存和查找号码,但是写的有点恶心。代码:# include <stdio.h># include <string.h>typedef struct TRIE{ int end ; int next[10] ;} TRIE ;TRIE trie[100010] ;int cnt ;char tb(char ch){return ch-'0';}i 阅读全文
posted @ 2012-04-11 02:15 Seraph2012 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2192题意:n个size不同的大楼,相同size的不能放在同一MagicBuilding中。问至少要多少个MagicBuilding。mark:其实就是求出现最多的那个数出现的次数,排序以后扫一次就好了。代码:# include <stdio.h># include <stdlib.h>int a[10010] ;int cmp(const void *a, const void *b){ return *(int*)a - *(int*) b ;}int main (){ in 阅读全文
posted @ 2012-04-11 01:55 Seraph2012 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1492题意:丑数(humble number)是一种素因子只有2、3、5、7组成的数字。给一个丑数,问它有多少因数。mark:基础数论。因为只有2、3、5、7四种素因子,因此只要求出幂次,加1后乘起来就好了。注意要用long long。代码:# include <stdio.h>long long div(long long x, int b){ int rtn = 0 ; while (x%b==0) { x /= b ; rtn ++ ; } ... 阅读全文
posted @ 2012-04-11 01:47 Seraph2012 阅读(377) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2601题意:给n,找满足i*j+i+j == n的一对(i,j),其中0<i<=j<n。mark:两边同时+1后得到(n+1)=(i+1)*(j+1)。只要从2到sqrt(n+1)枚举i+1的值就好了。不过时间有点久,2000+ms。正规的做法应该是用数论知识分解素因子。另外要考虑n是10^10,用long long(此处wa了一次)。代码:# include <stdio.h># include <math.h>int main (){ int T, sum, 阅读全文
posted @ 2012-04-11 01:40 Seraph2012 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 刚刚交了1506,无意间瞟到左边的随笔数,发现已经401题了,这么说前几天就400题了啊囧。昨天还想交到400题就先放放,背单词的,没想到那么快。等把USACO那个八皇后写完吧。人生总是有许多不想做又不得不做的事情。。。还记得刚接触acm的时候,听说题量300题是铜,400题是银,500题是金。当时觉得,我靠这么多,不至于吧。。。现在看来这个数还少了,而且还要看ac的是水题还是难题,这个差距还蛮大的。 阅读全文
posted @ 2012-02-26 06:59 Seraph2012 阅读(170) 评论(3) 推荐(1) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1506题意:给一些连续的直方柱的高(宽是1),找一个面积最大的矩形。mark:本来是个单调队列题,但是dp好像可以解。考虑每个柱往两边找能扩展到的最远的边界,乘上自己的高可获得。往两边扩展边界的时候理论复杂度是O(n),直接做是要TLE的。先考虑往右找边界,假设之前右边所有的直方柱的边界已经被找过,并且被记录下来,假如下一个柱的高度比自己高,则直接可以跳到下一个柱的边界继续找,不断迭代后很快就能找到边界。不知道这种迭代的方法复杂度如何证明,对于每个柱子,最坏的肯定是要找n次(递减),但是最坏的情况不可能 阅读全文
posted @ 2012-02-26 06:55 Seraph2012 阅读(647) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 51 下一页