上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 51 下一页
摘要: 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 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(140) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 51 下一页