随笔分类 -  HDOJ

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 24 下一页

发布一些HDOJ的做题情况以及代码。
[恢]hdu 1283
摘要:2011-12-17 07:35:12地址:http://acm.hdu.edu.cn/showproblem.php?pid=1283题意:中文。模拟题。代码:# include <stdio.h>char str[1010] ;int r1, r2, r3 ;int m1, m2 ;void handle(){ int i ; r1 = r2 = r3 = 0 ; for (i = 0 ; str[i] ; i++) { switch (str[i]) { case 'A': r1 = m1 ; break ; ... 阅读全文

posted @ 2012-01-06 22:13 Seraph2012 阅读(124) 评论(0) 推荐(0)

[恢]hdu 1257
摘要:2011-12-17 07:29:24地址:http://acm.hdu.edu.cn/showproblem.php?pid=1257题意:中文。最少拦截系统。mark:经典dp。最少拦截系统数=最长非降子序列(LIS)数。O(n^2)水过。代码:# include <stdio.h>int a[1010] ;int dp[1010] ;int n ;int max(int a, int b){return a>b?a:b;}int lis(){ int i, j, ans = 0 ; dp[0] = 1 ; for (i = 1 ;i < n ; i++) { .. 阅读全文

posted @ 2012-01-06 22:12 Seraph2012 阅读(128) 评论(0) 推荐(0)

[恢]hdu 1159
摘要:2011-12-17 07:19:48地址:http://acm.hdu.edu.cn/showproblem.php?pid=1159题意:求两个字符串的最长公共字串(LCS)。mark:经典dp。dp[i][j]表示a的前i个字符和j的前i个字符的LCS长度。有dp[i][j] = max(dp[i-1][j-1]+(a[i]==b[j]), dp[i-1][j], dp[i][j-1])。代码:# include <stdio.h># include <string.h>int dp[1010][1010] ;char s1[1010], s2[1010] ;in 阅读全文

posted @ 2012-01-06 22:11 Seraph2012 阅读(148) 评论(0) 推荐(0)

[恢]hdu 2072
摘要:2011-12-17 07:00:30地址:http://acm.hdu.edu.cn/showproblem.php?pid=2072题意:中文。统计“不同”单词。字符串处理。代码:# include <stdio.h># include <string.h>char str[1010] ;char words[1010][50] ;int n ;void getword(char str[]){ int flag = 0 ; int len = strlen(str) ; int cnt = 0 ; char word[50] ; int i ; str... 阅读全文

posted @ 2012-01-06 22:10 Seraph2012 阅读(148) 评论(0) 推荐(0)

[恢]hdu 2024
摘要:2011-12-17 06:52:15地址:http://acm.hdu.edu.cn/showproblem.php?pid=2024题意:中文。经典c问题。代码:# include <stdio.h>char str[1010] ;int test (char s[]){ int i ; if (s[0] >= '0' && s[0] <= '9') return 0 ; for (i = 0 ; s[i] ; i++) { if (s[i] == '_') continue ; if (s[i] &g 阅读全文

posted @ 2012-01-06 22:09 Seraph2012 阅读(159) 评论(0) 推荐(0)

[恢]hdu 1996
摘要:2011-12-17 06:48:26地址:http://acm.hdu.edu.cn/showproblem.php?pid=1996题意:中文。mark:每个数字都可能出现在3根柱子上。所以是3^n。代码:# include <stdio.h>long long dp[35] = {1} ;int main (){ int i, n ; for (i = 1 ; i <= 30 ; i++) dp[i] = dp[i-1] * 3 ; scanf ("%d", &n) ; while (~scanf ("%d", & 阅读全文

posted @ 2012-01-06 22:05 Seraph2012 阅读(147) 评论(0) 推荐(0)

[恢]hdu 1995
摘要:2011-12-17 06:44:26地址:http://acm.hdu.edu.cn/showproblem.php?pid=1995题意:中文。mark:其实越小的盘子移动次数越多。每个盘子是以前的盘子的2倍。1、2、4、8……代码:# include <stdio.h>int main (){ int T, n, num ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d", &n, &num) ; printf ("%I64d\n", 1LL &l 阅读全文

posted @ 2012-01-06 22:04 Seraph2012 阅读(117) 评论(0) 推荐(0)

[恢]hdu 1259
摘要:2011-12-17 06:39:22地址:http://acm.hdu.edu.cn/showproblem.php?pid=1259题意:中文。水题,直接模拟。代码:# include <stdio.h>int main (){ int i, T, m, a, b, t ; int tab[10] ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &m) ; for (i = 1 ; i<= 7 ; i++) tab[i] = i ; while (... 阅读全文

posted @ 2012-01-06 22:03 Seraph2012 阅读(131) 评论(0) 推荐(0)

[恢]hdu 1977
摘要:2011-12-17 06:38:31地址:http://acm.hdu.edu.cn/showproblem.php?pid=1977题意:输出第n行右边的两个数。mark:其实就是立方。要用long long,其实n达不到2100000,不然都该溢出了。代码:# include <stdio.h>int main (){ int T ; long long n ; scanf ("%d", &T) ; while (T--) { scanf ("%I64d", &n) ; printf ("%I64d %I64d 阅读全文

posted @ 2012-01-06 22:01 Seraph2012 阅读(146) 评论(0) 推荐(0)

[恢]hdu 1976
摘要:2011-12-17 06:28:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=1976题意:中文。代码:# include <stdio.h>int cmp(int a[3], int b[3]){ if (a[0] != b[0]) return a[0] < b[0] ; if (a[1] != b[1]) return a[1] < b[1] ; if (a[2] != b[2]) return a[2] < b[2] ; return 2 ;}int main (){ char rst[3][10] = { 阅读全文

posted @ 2012-01-06 21:04 Seraph2012 阅读(163) 评论(0) 推荐(0)

[恢]hdu 1982
摘要:2011-12-17 06:22:49地址:http://acm.hdu.edu.cn/showproblem.php?pid=1982题意:#表示空格 -无意义 数字对应'A'-'Z'。字符串处理。代码:# include <stdio.h># include <string.h>char str[10010] ;void output (char str[]){ int i, flag = 0, num ; for (i = 0 ; str[i] ; i++) { if (flag == 0) { if (str[i] >... 阅读全文

posted @ 2012-01-06 18:48 Seraph2012 阅读(136) 评论(0) 推荐(0)

[恢]hdu 1985
摘要:2011-12-17 06:13:33地址:http://acm.hdu.edu.cn/showproblem.php?pid=1985题意:单位换算。mark:打表非常方便。代码:# include <stdio.h># include <string.h>char tab[4][5] = {"kg", "lb", "l", "g"} ;char outtab[4][5] = {"lb", "kg", "g", "l&q 阅读全文

posted @ 2012-01-06 18:47 Seraph2012 阅读(172) 评论(0) 推荐(0)

[恢]hdu 1984
摘要:2011-12-17 06:05:08地址:http://acm.hdu.edu.cn/showproblem.php?pid=1984题意:删除字符串中的第n个字符。mark:利用字符串拼接。代码:# include <stdio.h>char str[100] ;int main (){ int T, n, nCase = 1 ; scanf ("%d%*c", &T) ; while (T--) { scanf ("%d %s%*c", &n, str) ; str[n-1] = '\0' ; print 阅读全文

posted @ 2012-01-06 18:46 Seraph2012 阅读(149) 评论(0) 推荐(0)

[恢]hdu 1998
摘要:2011-12-17 05:51:13地址:http://acm.hdu.edu.cn/showproblem.php?pid=1998题意:中文。代码:# include <stdio.h># include <string.h>int dp[25][25] ;void generate(int n){ int i, x = 0, y = n/2, xx, yy ; memset(dp, 0, sizeof(dp)) ; for (i = 1 ; i <= n*n ; i++) { dp[x][y] = i ; xx = (x-1 + n)... 阅读全文

posted @ 2012-01-06 18:45 Seraph2012 阅读(142) 评论(0) 推荐(0)

[恢]hdu 1994
摘要:2011-12-17 06:00:46地址:http://acm.hdu.edu.cn/showproblem.php?pid=1994题意:中文。mark:阅读题,各种绕。公式:y*(1+e/100*q/365)*(1+g/100),y*(1+f/100*(q+365)/365)。代码:# include <stdio.h>int main (){ int T ; double y, q, e, f, g ; scanf ("%d", &T) ; while (T--) { scanf ("%lf%lf%lf%lf%lf", &am 阅读全文

posted @ 2012-01-06 18:45 Seraph2012 阅读(155) 评论(0) 推荐(0)

[恢]hdu 1052
摘要:2011-12-17 04:11:34地址:http://acm.hdu.edu.cn/showproblem.php?pid=1052题意:田忌赛马,给n个马匹的速度,胜+200,负-200,平的话什么都不做。问最多得多少钱。mark:写了一个二分图匹配,但是发现有平的情况真是非常不好处理,应该需要最佳匹配才能解决。这里直接用贪心的结论了。代码:# include <stdio.h># include <stdlib.h>int a[1010], b[1010] ;int n ;int gao(){ int i ; int p1=0,p2=0,q1=n-1,q2=n- 阅读全文

posted @ 2012-01-06 18:44 Seraph2012 阅读(213) 评论(0) 推荐(0)

[恢]hdu 2054
摘要:2011-12-17 01:37:11地址:http://acm.hdu.edu.cn/showproblem.php?pid=2054题意:输入2个数字,问你是否相等(大数)。mark:RE1次,数组要开到10w。。。蛋疼。这题其实简单,依次做三件事:加小数点(若无小数点),去末尾0,去前导0。没有负数的情况。代码:# include <stdio.h># include <string.h>char s1[100010], s2[100010] ;void AddDecimal (char *s){ int i ; for (i = 0 ; s[i] ; i++) 阅读全文

posted @ 2012-01-06 18:43 Seraph2012 阅读(226) 评论(0) 推荐(0)

[恢]hdu 1106
摘要:2011-12-17 01:26:33地址:http://acm.hdu.edu.cn/showproblem.php?pid=1106题意:中文。字符串处理,总觉得写的不完满。代码:# include <stdio.h># include <stdlib.h># include <string.h>char str[1010] ;int a[1010] ;int cmp(const void *a, const void *b){ return *(int*)a - *(int*)b ;}int main (){ int cnt = 0, flag = 0 阅读全文

posted @ 2012-01-06 17:45 Seraph2012 阅读(163) 评论(0) 推荐(0)

[恢]hdu 1207
摘要:2011-12-17 00:08:43地址:http://acm.hdu.edu.cn/showproblem.php?pid=1207题意:中文,不说。mark:n最大到64。dp方程很容易出,但是64的时候不好处理。用double打表知64的答案是18433,特判一下。代码:# include <stdio.h>long long dp[70] = {0, 1, 3, 5} ;long long min(long long a, long long b){return a<b?a:b;}int main (){ int i, j, n ; dp[64] = 18433 ; 阅读全文

posted @ 2012-01-06 17:44 Seraph2012 阅读(174) 评论(0) 推荐(0)

[恢]hdu 2037
摘要:2011-12-16 23:10:35地址:http://acm.hdu.edu.cn/showproblem.php?pid=2037题意:中文,不解释。mark:贪心,按结束时间排序。代码:# include <stdio.h># include <stdlib.h>typedef struct node{ int s, t ;}node ;node a[110] ;int cmp(const void*a, const void *b){ node *p = (node*)a, *q = (node*)b ; if (p->t != q->t) ret 阅读全文

posted @ 2012-01-06 17:43 Seraph2012 阅读(200) 评论(0) 推荐(0)

上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 24 下一页