随笔分类 -  HDOJ

发布一些HDOJ的做题情况以及代码。
[恢]hdu 2011
摘要:2011-12-14 05:09:52地址:http://acm.hdu.edu.cn/showproblem.php?pid=2011题意:中文。。。代码:# include <stdio.h>int main (){ int T, n ; double sum ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; sum = 0 ; while (n--) { sum += 1.0 / (n&1 ? n+1 : -1-n) ; ... 阅读全文

posted @ 2012-01-06 14:37 Seraph2012 阅读(127) 评论(0) 推荐(0)

[恢]hdu 2000
摘要:2011-12-14 05:14:05地址:http://acm.hdu.edu.cn/showproblem.php?pid=2000题意:中文。。。代码:# include <stdio.h>char max(char c1, char c2){return c1>c2?c1:c2;}char min(char c1, char c2){return c1<c2?c1:c2;}int main (){ char a,b,c,aa,bb,cc ; while (~scanf ("%c%c%c",&a,&b,&c)) { ge 阅读全文

posted @ 2012-01-06 14:37 Seraph2012 阅读(145) 评论(0) 推荐(0)

[恢]hdu 2040
摘要:2011-12-14 05:05:59地址:http://acm.hdu.edu.cn/showproblem.php?pid=2040题意:中文。代码:# include <stdio.h>int gao(int n){ int i, sum = 0 ; for (i =1 ; i < n ; i++) if (n%i==0) sum += i ; return sum ;}int main (){ int T, a, b ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d", .. 阅读全文

posted @ 2012-01-06 14:36 Seraph2012 阅读(116) 评论(0) 推荐(0)

[恢]hdu 2033
摘要:2011-12-14 04:59:10地址:http://acm.hdu.edu.cn/showproblem.php?pid=2033题意:中文,时间相加。代码:# include <stdio.h>int main (){ int T ; int h, m, s, hh, mm, ss ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d%d%d%d%d", &h, &m, &s, &hh, &mm, &ss) ; s += ss ; if 阅读全文

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

[恢]hdu 2039
摘要:2011-12-14 05:02:21地址:http://acm.hdu.edu.cn/showproblem.php?pid=2039题意:中文,判断合法三角形。mark:wa了一次。输入的是实数不是int,坑爹。代码:# include <stdio.h>int main (){ int T ; double a, b, c ; scanf ("%d", &T) ; while (T--) { scanf ("%lf%lf%lf", &a, &b, &c) ; if (a+b<=c || b+c< 阅读全文

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

[恢]hdu 2032
摘要:2011-12-14 04:47:31地址:http://acm.hdu.edu.cn/showproblem.php?pid=2032题意:中文。代码:# include <stdio.h>int tri[35][35] ;void output (int n){ int i, j ; for (i = 0 ; i < n ; i++) { for (j = 0 ; j < i+1 ; j++) if (j == 0) printf ("%d", tri[i][j] ) ; else printf (" %d", t... 阅读全文

posted @ 2012-01-06 14:33 Seraph2012 阅读(145) 评论(0) 推荐(0)

[恢]hdu 2042
摘要:2011-12-14 04:53:04地址:http://acm.hdu.edu.cn/showproblem.php?pid=2042题意:中文。。。递推。代码:# include <stdio.h>int dp[35] = {3} ;int main (){ int i, n, num ; for (i = 1 ; i <= 30 ; i++) dp[i] = (dp[i-1]-1) * 2 ; scanf ("%d", &n) ; while (n--) { scanf ("%d", &num) ; printf 阅读全文

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

[恢]hdu 2020
摘要:2011-12-14 04:39:31地址:http://acm.hdu.edu.cn/showproblem.php?pid=2020题意:中文代码:# include <stdio.h># include <stdlib.h>int a[110] ;int abs(int n){return n<0?-n:n;}int cmp(const void *a, const void *b){ int aa = *(int*)a, bb = *(int*)b ; return abs(bb)-abs(aa) ;}int main (){ int i, n ; whi 阅读全文

posted @ 2012-01-06 14:32 Seraph2012 阅读(158) 评论(0) 推荐(0)

[恢]hdu 2016
摘要:2011-12-14 04:21:57地址:http://acm.hdu.edu.cn/showproblem.php?pid=2016题意:中文。mark:wa了2次,a^=b^=a^=b这种交换只能用在a和b不同的时候,否则清零。没考虑第一个元素就是最小值的情况。代码:# include <stdio.h>int a[110] ;int main (){ int i, n, pos ; while (~scanf ("%d", &n) && n) { for (i = 0 ; i < n ;i++) scanf ("% 阅读全文

posted @ 2012-01-06 14:29 Seraph2012 阅读(196) 评论(0) 推荐(0)

[恢]hdu 2019
摘要:2011-12-14 04:31:11地址:http://acm.hdu.edu.cn/showproblem.php?pid=2019题意:中文。代码:# include <stdio.h># define INF 0x7f7f7f7fint flag ;void output (int num){ if (flag == 0) flag = 1; else putchar (' ') ; printf ("%d", num) ;}int main (){ int n, m, num ; while (~scanf ("%d%d&qu 阅读全文

posted @ 2012-01-06 14:29 Seraph2012 阅读(188) 评论(0) 推荐(0)

[恢]hdu 2007
摘要:2011-12-14 03:57:54地址:http://acm.hdu.edu.cn/showproblem.php?pid=2007题意:中文。。。mark:wa了一次,忽略了m和n大小关系不固定。代码:# include <stdio.h>int main (){ int i, a1, a2, n, m ; while (~scanf ("%d%d", &n, &m)) { a1 = a2 = 0 ; if (n > m) n^=m^=n^=m ; for (i = n ; i <= m ; i++) { ... 阅读全文

posted @ 2012-01-06 14:28 Seraph2012 阅读(132) 评论(0) 推荐(0)

[恢]hdu 2010
摘要:2011-12-14 04:06:19地址:http://acm.hdu.edu.cn/showproblem.php?pid=2010题意:中文。。。代码:# include <stdio.h>int main (){ int i, a, b, flag ; int daff[4] = {153, 370, 371, 407} ; while (~scanf ("%d%d", &a, &b)) { flag = 0 ; for (i = 0 ; i < 4 ; i++) if (daff[i] >= a && daf 阅读全文

posted @ 2012-01-06 14:28 Seraph2012 阅读(173) 评论(0) 推荐(0)

[恢]hdu 2029
摘要:2011-12-14 03:51:49地址:http://acm.hdu.edu.cn/showproblem.php?pid=2029题意:中文题。代码:# include <stdio.h># include <string.h>int IsPalindromes(char str[]){ int i, len = strlen (str) ; for (i = 0 ; i < len/2 ; i++) if (str[i] != str[len-i-1]) return 0 ; return 1 ;}int main (){ int n ; c... 阅读全文

posted @ 2012-01-06 14:27 Seraph2012 阅读(158) 评论(0) 推荐(0)

[恢]hdu 2021
摘要:2011-12-14 03:40:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2021题意:中文题。代码:# include <stdio.h>int gao(int num){ int sum = 0, i, tab[] = {100, 50, 10, 5, 2, 1} ; for (i = 0 ; i < 6 ; i++) { sum += num / tab[i] ; num %= tab[i] ; } return sum ;}int main (){ int n, num... 阅读全文

posted @ 2012-01-06 14:26 Seraph2012 阅读(186) 评论(0) 推荐(0)

[恢]hdu 2022
摘要:2011-12-14 03:47:02地址:http://acm.hdu.edu.cn/showproblem.php?pid=2022题意:中文题。代码:# include <stdio.h>int ABS(int n){return n<0?-n:n;}int main (){ int n, m, x, y ; int i, j, num, nnum, max ; while (~scanf ("%d%d", &n, &m)) { max = -1 ; for (i = 0 ; i < n ; i++) for (j... 阅读全文

posted @ 2012-01-06 14:26 Seraph2012 阅读(194) 评论(0) 推荐(0)

[恢]hdu 2014
摘要:2011-12-12 05:46:08地址:http://acm.hdu.edu.cn/showproblem.php?pid=2014题意:中文题。mark:wa了3次!!!因为敲错变量!!!min敲成了num,各种二。可能是困了。代码:# include <stdio.h># define MAX(a,b) (a>b?a:b)# define MIN(a,b) (a<b?a:b)int main (){ int sum, max, min, num ; int n, i ; while (~scanf ("%d", &n)) { scan 阅读全文

posted @ 2012-01-06 14:25 Seraph2012 阅读(141) 评论(0) 推荐(0)

[恢]hdu 2018
摘要:2011-12-12 05:57:29地址:http://acm.hdu.edu.cn/showproblem.php?pid=2018题意:中文题。mark:”第四年“意味着出生年隔2年。递推,方程是dp[i] = dp[i-1]+dp[i-3],就是去年的牛加上大前年能的牛生的宝宝们。代码:# include <stdio.h>int main (){ int i, dp[60] = {0, 1, 2, 3, 4} ; for (i = 4 ; i < 55 ; i++) dp[i] = dp[i-1]+dp[i-3] ; while (~scanf ("%.. 阅读全文

posted @ 2012-01-06 14:25 Seraph2012 阅读(244) 评论(1) 推荐(0)

[恢]hdu 2012
摘要:2011-12-12 05:27:32地址:http://acm.hdu.edu.cn/showproblem.php?pid=2012题意:中文题。mark:wa了一次,超2的。自己以为聪明地写了一个预处理,结果忘记把表达式写进去了,IsPrme的参数直接写了个i,太2了。代码:# include <stdio.h>int IsPrime(int n){ int i ; for (i = 2 ; i < n ; i++) if (n%i==0) break ; return i >= n ;}int main (){ int i, tab[100] = ... 阅读全文

posted @ 2012-01-06 14:24 Seraph2012 阅读(223) 评论(0) 推荐(0)

[恢]hdu 2017
摘要:2011-12-12 05:18:17地址:http://acm.hdu.edu.cn/showproblem.php?pid=2017题意:中文题。mark:wa了一次,忘记在组数后加getchar。。。太2了。代码:# include <stdio.h>char str[1010] ;int main (){ int i, sum ; scanf ("%d", &i) ; getchar () ; while (gets(str)) { for (sum = 0, i = 0 ; str[i] ; i++) if (str[... 阅读全文

posted @ 2012-01-06 14:23 Seraph2012 阅读(166) 评论(0) 推荐(0)

[恢]hdu 2013
摘要:2011-12-12 05:10:11地址:http://acm.hdu.edu.cn/showproblem.php?pid=2013题意:中文。思路:递推。设tab[n]表示第n天的桃子数。由题意知tab[n]/2-1 = tab[n-1],可得tab[n] = (tab[n-1]+1)*2。代码:# include <stdio.h># include <math.h>int main (){ int i, tab[30] = {0, 1} ; for (i = 2 ; i < 30 ; i++) tab[i] = (tab[i-1]+1) * 2 ; w. 阅读全文

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