上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 51 下一页
摘要: 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 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 2011-12-29 13:51:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2554题意:中文,有点绕但是能看懂,不多说了。mark:着实不会,看了网上的规律觉得好扯淡。n%4的余数是3或0的就是Y,否则是N。。。不知道怎么来的,打表也只能看到前12项,之后就非常慢了。代码(C编译):main(n){while(scanf("%d",&n),n){puts((n+1)&2?"N":"Y");}}打表的程序也贴一下吧:# include <stdio.h> 阅读全文
posted @ 2012-01-07 00:02 Seraph2012 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 2011-12-29 22:32:38地址:http://acm.hdu.edu.cn/showproblem.php?pid=2555题意:中文。不多解释。mark:此题真是坑爹。数据里有多个矩形覆盖一个点的情况- -。。。如果有这种情况,就算前一个矩形的周长。。。另外,在矩形边上也算是包含在陷阱内。代码:# include <stdio.h># include <string.h># include <stdlib.h>typedef struct point{ int x, y ;}point ;point pt[20010] ;int a[110][ 阅读全文
posted @ 2012-01-07 00:02 Seraph2012 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 2011-12-28 09:55:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2560题意:给n*m的0-1矩阵,问有多少个1。。。mark:这么水的题好爽!代码:# include <stdio.h>int main (){ int T, n, m, i, num, sum ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d", &n, &m) ; sum = 0 ; for (i = 0 ; i < n*m ; i+ 阅读全文
posted @ 2012-01-07 00:00 Seraph2012 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 2011-12-28 09:47:29地址:http://acm.hdu.edu.cn/showproblem.php?pid=1907题意:n堆石子,每次取走其中一堆的任意颗,最后一个取的人败,求判局势。mark:anti-nim,开始以为很简单,其实很难分析,搞了好久。具体可以参见2009年国家集训队贾志豪的论文。这里先给出anti-nim的结论:先手必胜当且仅当:1)sg值为0且不存在一堆sg值大于1;2)sg不为0且存在至少一堆sg值大于1。代码:# include <stdio.h>int main (){ int T, n, num, sg, flag ; scanf 阅读全文
posted @ 2012-01-06 23:59 Seraph2012 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 16:18:37地址:http://acm.hdu.edu.cn/showproblem.php?pid=2553题意:求n皇后放置的种类数。mark:因为n才10,所以直接dfs。代码:# include <stdio.h>int n, dp[11] = {0, 1} ;int ans, num[11] ;int col[11], diag[30], indiag[100] ;void dfs(int pos){ int i, j ; if (pos == n) { ans ++ ; return ; } for... 阅读全文
posted @ 2012-01-06 23:58 Seraph2012 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 16:40:47地址:http://acm.hdu.edu.cn/showproblem.php?pid=2082题意:中文。mark:YY了一个dp。dp[i][j]表示前i个字符组成价值为j的种类数,有dp[i][j] = dp[i-1][j-k*i],k∈[0,a[i]]。a[i]是第i个字符的最大个数。最后把dp[26]的所有值(0除外)加起来就ok了。代码:# include <stdio.h># include <string.h>int dp[30][60] ;int a[30] ;int main (){ int T, i, j, 阅读全文
posted @ 2012-01-06 23:58 Seraph2012 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 15:46:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=1326题意:n个高矮不等的堆。每次可以从一个堆拿一块移动到另一堆。问最少移动多少次能使他们全都相等。mark:好经典的题目,不记得在哪儿看到过不只1次了。每个和平均数的差加起来除以二。代码:# include <stdio.h>int num[60] ;int n ;int abs(int n){return n<0?-n:n;}int main (){ int i, sum ,ans, nCase = 1 ; while (~scanf (&qu 阅读全文
posted @ 2012-01-06 23:57 Seraph2012 阅读(190) 评论(0) 推荐(0) 编辑
上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 51 下一页