随笔分类 -  HDOJ

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 24 下一页

发布一些HDOJ的做题情况以及代码。
[恢]hdu 2565
摘要:2011-12-31 19:19:52地址:http://acm.hdu.edu.cn/showproblem.php?pid=2565题意:中文,模拟。代码:# include <stdio.h># include <string.h>char graph[100] ;void output (int n){ int i ; memset (graph, ' ', sizeof (graph)) ; for (i = 0 ; i < n ; i++) { memset(graph, ' ', sizeof(graph)) ; gr 阅读全文

posted @ 2012-01-07 00:28 Seraph2012 阅读(209) 评论(0) 推荐(0)

[恢]hdu 2561
摘要:2011-12-31 19:02:16地址:http://acm.hdu.edu.cn/showproblem.php?pid=2561题意:中文。mark:可以排序,不过也可以扫一遍。用a记录最小值,b记录次小值,更新。代码:# include <stdio.h>int main (){ int T, a, b, i, n, num ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; a = b = 1000 ; for (i = 0 ; i < n ; i++) 阅读全文

posted @ 2012-01-07 00:27 Seraph2012 阅读(127) 评论(0) 推荐(0)

[恢]hdu 2566
摘要:2011-12-31 19:13:38地址:http://acm.hdu.edu.cn/showproblem.php?pid=2566题意:中文。。。mark:题目没给数据范围,实在蛋疼,水了一下。考虑到如果有n个硬币,全都是1或2,能组成[n,2n]区间内任何一个数。所以枚举面额为5的硬币个数,然后计算剩下的面额是否在剩下的1、2硬币组成的面额区间内。15ms。那个dp[]数组没用,一开始看错题了。代码:# include <stdio.h>int dp[] = {1, 1, 2, 3, 5, 9} ;int main (){ int T, i, n, m, nn, mm, a 阅读全文

posted @ 2012-01-07 00:27 Seraph2012 阅读(248) 评论(0) 推荐(0)

[恢]hdu 2562
摘要:2011-12-31 18:58:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=2562题意:中文。有点不明确,其实就是第0个和第1个互换,第二个和第三个互换。。。代码:# include <stdio.h>char str[100] ;int main (){ int T, i ; scanf ("%d", &T) ; while (T--) { scanf ("%s%*c", str) ; for (i = 0 ; str[i] ; i+=2) printf ("%c%.. 阅读全文

posted @ 2012-01-07 00:25 Seraph2012 阅读(111) 评论(0) 推荐(0)

[恢]hdu 2564
摘要:2011-12-31 18:53:55地址:http://acm.hdu.edu.cn/showproblem.php?pid=2564题意:中文。。。没啥好说的,处理就行了。代码:# include <stdio.h>char str[1000] ;void output(char str[]){ int i ; for(i = 0 ; str[i] ; i++) { if ((i == 0 || str[i-1] == ' ') && str[i] != ' ') putchar (str[i] & 0xDF) ; }}i 阅读全文

posted @ 2012-01-07 00:24 Seraph2012 阅读(148) 评论(0) 推荐(0)

[恢]hdu 1548
摘要:2011-12-31 18:44:21地址:http://acm.hdu.edu.cn/showproblem.php?pid=1548题意:有一个奇怪的电梯,只有2个按钮,上和下。第i楼层有一个值Ki。假设在第i层,按上它会向上走Ki层,按下也一样。如果超过n层或少于1层,则原地不动。问从第a层到b层需要几次操作。mark:BFS之。代码:# include <stdio.h># include <string.h>int aa, bb, n ;int k[210] ;int q[210] ;int step[210] ;void bfs(){ int a, fron 阅读全文

posted @ 2012-01-07 00:23 Seraph2012 阅读(161) 评论(0) 推荐(0)

[恢]hdu 2102
摘要:2011-12-31 18:20:59地址:http://acm.hdu.edu.cn/showproblem.php?pid=2102题意:中文。。。mark:你大爷的WA+TLE一共11次才AC。做了至少8个小时。一开始以为是要在严格的T时刻到达才可以,考虑了不可回头和可回头两种情况,dfs之,TLE。。。然后加奇偶剪,还是TLE。之后搜了搜,发现时T时刻以内到都可以,然后拍了个BFS。WA。WA了n次以后才发现时空传送是一定要传送的,不是自己选可以传也可以不传的。然后还WA,想是不是真的要在T时刻才能过,然后加了奇偶剪枝(因为回头路的话可以无限延长时间),还WA。最后发现一个trick是 阅读全文

posted @ 2012-01-07 00:22 Seraph2012 阅读(195) 评论(0) 推荐(0)

[恢]hdu 1240
摘要:2011-12-31 10:46:23地址:http://acm.hdu.edu.cn/showproblem.php?pid=1240题意:给n*n*n的三维迷宫,求从起点到终点的最短步数。mark:bfs搞之。注意起点和终点也可以是'X'的情况。代码:# include <stdio.h># include <string.h>char graph[15][15][15] ;int step[15][15][15] ;int q[1010][3] ;int tab[6][3] = { {-1, 0, 0}, {1, 0, 0}, {0, -1,... 阅读全文

posted @ 2012-01-07 00:21 Seraph2012 阅读(127) 评论(0) 推荐(0)

[恢]hdu 1238
摘要:2011-12-31 10:01:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=1238题意:给n个字符串,要求找字符串符合该串是所有给出的字符串或给出字符串的反串的子串的。求最大长度。mark:先在输入的时候顺便存储所有串的反串,然后枚举第一个串的所有子串,最后kmp比较。代码:# include <stdio.h># include <string.h>char ss[110][110] ;char sr[110] ;int next[110] = {-1} ;int n ;void getnext(char str[ 阅读全文

posted @ 2012-01-07 00:14 Seraph2012 阅读(198) 评论(0) 推荐(0)

[恢]hdu 1239
摘要:2011-12-31 01:58:02地址:http://acm.hdu.edu.cn/showproblem.php?pid=1239题意:给m、a、b。求一对素数p,q(p<q)使得p*q<=m且p/q >= a/b。若有多对,输出p*q最大的一对。mark:刚开题看了半天,才看明白啥意思。看到m是10w,然后case是2000组,一下懵了,以为不能枚举。后来冷静分析下,其实可以。以下是几个比较重要的结论&分析。1)若m' = p*q,则必不存在另外一对素数p',q'使得m' = p' * q'。2) 若p固定,q要 阅读全文

posted @ 2012-01-07 00:13 Seraph2012 阅读(178) 评论(0) 推荐(0)

[恢]hdu 2141
摘要:2011-12-30 19:52:14地址:http://acm.hdu.edu.cn/showproblem.php?pid=2141题意:给一串ai、bj、ck,一串x,问x是否能表示成ai+bj+ck。mark:不会,搜了一下。把ai+bj存起来。然后二分x-ck。。。复杂度应该是O(500*500 + lg(250000)*500)好极限。代码:# include <stdio.h># include <stdlib.h>int a[510], b[510], c[510] ;int ab[510*510] ;int cmp(const void *a, con 阅读全文

posted @ 2012-01-07 00:12 Seraph2012 阅读(145) 评论(0) 推荐(0)

[恢]hdu 2563
摘要:2011-12-30 19:16:59地址:http://acm.hdu.edu.cn/showproblem.php?pid=2563题意:中文。递推。代码:# include <stdio.h>int dp[25][2] = {1, 0} ;int main (){ int i, n ; for (i = 1 ; i <= 20 ; i++) { dp[i][0] = dp[i-1][0] + dp[i-1][1] ; dp[i][1] = dp[i][0] + dp[i-1][0] ; } scanf ("%d", &n) ; ... 阅读全文

posted @ 2012-01-07 00:11 Seraph2012 阅读(222) 评论(0) 推荐(0)

[恢]hdu 1597
摘要:2011-12-30 18:25:02地址:http://acm.hdu.edu.cn/showproblem.php?pid=1597题意:中文。。。mark:要用long long。代码:# include <stdio.h># include <math.h>int main (){ long long n, a ; scanf ("%I64d", &n) ; while (~scanf ("%I64d", &n)) { a = (sqrt(1.0+8.0*n)-1) / 2 ; if (a*(a+1)/2 阅读全文

posted @ 2012-01-07 00:10 Seraph2012 阅读(261) 评论(0) 推荐(0)

[恢]hdu 1799
摘要:2011-12-30 17:35:04地址:http://acm.hdu.edu.cn/showproblem.php?pid=1799题意:中文。mark:其实就是组合数。。。因为m重循环就是在n个数字里选n个作为变量。。。代码:# include <stdio.h>int dp[2010][2010] ;void init(){ int i, j ; dp[0][0] = 1 ; for (i = 1 ; i <= 2000 ; i++) { dp[i][0] = 1 ; for (j = 1 ; j <= i ; j++) ... 阅读全文

posted @ 2012-01-07 00:09 Seraph2012 阅读(244) 评论(0) 推荐(0)

[恢]hdu 2078
摘要:2011-12-30 16:59:50地址:http://acm.hdu.edu.cn/showproblem.php?pid=2078题意:中文,不说了。其实和m没关系。代码:# include <stdio.h>int main (){ int T, i, n, m, a, min ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d", &n, &m) ; min = 100 ; for (i = 0 ; i < n ;i++) { scanf ... 阅读全文

posted @ 2012-01-07 00:08 Seraph2012 阅读(144) 评论(0) 推荐(0)

[恢]hdu 2089
摘要:2011-12-30 16:33:11地址:http://acm.hdu.edu.cn/showproblem.php?pid=2089题意:中文。。。mark:直接打表可过。代码:# include <stdio.h>int dp[1000010] ;int test (int num){ while (num) { if (num % 10 == 4 || num % 100 == 62) return 0 ; num /= 10 ; } return 1 ;}int main (){ int n, m, i ... 阅读全文

posted @ 2012-01-07 00:07 Seraph2012 阅读(258) 评论(0) 推荐(0)

[恢]hdu 2152
摘要:2011-12-30 16:20:20地址:http://acm.hdu.edu.cn/showproblem.php?pid=2152题意:中文。mark:dp搞起。代码:# include <stdio.h># include <string.h>int dp[110][110] ;int main (){ int n, m, a, b, i, j, k ; while (~scanf ("%d%d", &n, &m)) { memset (dp, 0, sizeof(dp)) ; dp[0][0] = 1 ; for (i = 阅读全文

posted @ 2012-01-07 00:06 Seraph2012 阅读(150) 评论(0) 推荐(0)

[恢]hdu 2203
摘要:2011-12-30 02:41:06地址:http://acm.hdu.edu.cn/showproblem.php?pid=2203题意:中文,字符串比较。mark:把第一个串复制一次接在自己后面。然后字符串比较。据说数据很水?!我就暴了一下,结果TLE。。。好吧,刚学了KMP,用上试试,果断0ms,威力果然不小,开心。代码:# include <stdio.h># include <string.h>char s1[200010], s2[100010] ;char buff[100010] ;int next[100010] = {-1} ;void getne 阅读全文

posted @ 2012-01-07 00:05 Seraph2012 阅读(199) 评论(0) 推荐(0)

[恢]hdu 2304
摘要:2011-12-29 23:20:50地址:http://acm.hdu.edu.cn/showproblem.php?pid=2304题意:说墙上一开始有一个插座。给n个接线板,每个有若干个可以用的插口,问能获得多少个插口。代码:# include <stdio.h>int main (){ int T, n, o, ans ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; ans = 1 ; while (n--) { scanf ... 阅读全文

posted @ 2012-01-07 00:04 Seraph2012 阅读(188) 评论(0) 推荐(0)

[恢]hdu 2317
摘要:2011-12-29 23:07:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=2317题意:给出不放广告的收入,放广告的收入和广告的花费,问结果。代码:# include <stdio.h>int main (){ int n ; int a, b, c ; scanf ("%d", &n) ; while (n--) { scanf ("%d%d%d", &a, &b, &c); if (b-c > a) puts ("advertise&qu 阅读全文

posted @ 2012-01-07 00:03 Seraph2012 阅读(145) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 24 下一页