随笔分类 -  HDOJ

发布一些HDOJ的做题情况以及代码。
[恢]hdu 2502
摘要:2011-12-15 03:44:22地址:http://acm.hdu.edu.cn/showproblem.php?pid=2502题意:中文。。。mark:应该有公式,不过直接递推吧。。。dp[i]表示所有长度小于等于i的数共有多少个1。代码:# include <stdio.h># include <stdlib.h>int dp[25] = {0, 1} ;int main (){ int i ; for (i = 2 ; i <= 20 ; i++) dp[i] = dp[i-1] * 2 + (1 << (i-1)) ; scanf (& 阅读全文

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

[恢]hdu 2535
摘要:2011-12-15 03:38:08地址:http://acm.hdu.edu.cn/showproblem.php?pid=2535题意:中文~mark:坑爹。wa了。是超过一半,不是超过或等于一半。代码:# include <stdio.h># include <stdlib.h>int cmp(const void *a, const void *b){ return *(int*)a - *(int*) b ;}int main (){ int n, i, sum ; int a[110] ; while (~scanf ("%d", &a 阅读全文

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

[恢]hdu 2500
摘要:2011-12-15 03:28:10地址:http://acm.hdu.edu.cn/showproblem.php?pid=2500题意:中文,水。代码:# include <stdio.h>int main (){ int T, n, i, j ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; for (i = 0 ; i < n*3 ; i++) { for (j = 0 ; j < n ; j++) print... 阅读全文

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

[恢]hdu 2073
摘要:2011-12-15 03:18:50地址:http://acm.hdu.edu.cn/showproblem.php?pid=2073题意:中文。。。mark:用一种比较奇怪的写法来写的。代码:# include <stdio.h># include <math.h>typedef struct PT{ int x, y ;}PT ;int cmp(const void *a, const void *b){ PT *p = (PT*)a, *q = (PT*)b ; if (p->x + p->y != q->x + q->y) return 阅读全文

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

[恢]hdu 1061
摘要:2011-12-15 03:01:19地址:http://acm.hdu.edu.cn/showproblem.php?pid=1061题意:求N^N的最后一位。mark:可以用快速幂,也可以直接用数论公式后循环。EulerPhi(10) = 4。代码:# include <stdio.h>int pp(int n, int m){ int i, mul = 1 ; for (i = 0 ; i < m ; i++) mul = (mul*n)%10 ; return mul % 10 ;}int main (){ int T, n ; scanf ... 阅读全文

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

[恢]hdu 2201
摘要:2011-12-15 02:57:40地址:http://acm.hdu.edu.cn/showproblem.php?pid=2201题意:中文。。。mark:废话超多。其实就是求第一个数的倒数,和第二个数无关。代码:# include <stdio.h>int main (){ int n , m; while (~scanf ("%d%d", &n, &m)) printf ("%.2lf\n", 1.0/(double)n) ; return 0 ;} 阅读全文

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

[恢]hdu 2186
摘要:2011-12-15 02:53:24地址:http://acm.hdu.edu.cn/showproblem.php?pid=2186题意:中文。。。最后一段之外都是剧情。地震,感慨。一晃快4年了。题目要写完满很麻烦,还好数据保证了很多情况不出现。代码:# include <stdio.h>int main (){ int n, T, a, b, c, ans ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; a = n/2 ; b = (n-a)*2/3 ; ... 阅读全文

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

[恢]hdu 2162
摘要:2011-12-15 02:43:48地址:http://acm.hdu.edu.cn/showproblem.php?pid=2162题意:输入一堆数,求和。代码:# include <stdio.h>int main (){ int n, sum, num ; int nCase = 1 ; while (~scanf ("%d", &n) && n > 0) { sum = 0 ; while (n--) { scanf ("%d", &num) ; sum += num ; ... 阅读全文

posted @ 2012-01-06 15:02 Seraph2012 阅读(122) 评论(0) 推荐(0)

[恢]hdu 2163
摘要:2011-12-15 02:48:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2163题意:判断是否是回文。。。代码:# include <stdio.h># include <string.h>int test(char str[]){ int i, len = strlen(str) ; for (i = 0 ; i < len/2 ; i++) if (str[i] != str[len-1-i]) return 0 ; return 1 ;}int main (){ int nCase = 1 ; ... 阅读全文

posted @ 2012-01-06 15:02 Seraph2012 阅读(208) 评论(0) 推荐(0)

[恢]hdu 2160
摘要:2011-12-15 02:39:10地址:http://acm.hdu.edu.cn/showproblem.php?pid=2160题意:中文。。。mark:直接用最暴力的递推水过。其实应该还是fibonacci。代码:# include <stdio.h>int main (){ int i, T, n ; int dp[25][3] ; dp[1][0] = 1 ; dp[1][1] = dp[1][2] = 0 ; for (i = 2 ; i <= 20 ; i++) { dp[i][0] = dp[i-1][0] + dp[i-1... 阅读全文

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

[恢]hdu 2140
摘要:2011-12-15 02:28:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=2140题意:给出加密的字符串,输出解密。加密规则在题中。mark:那个l很像1……wa了一次,没看数组范围,开了个100的,2B了。代码:# include <stdio.h>char tab[300] ;char str[10010] ;int main (){ int i ; char s1[] = "bqtmicael", s2[] = " ,!leacim" ; for (i = 0 ; i < 9 阅读全文

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

[恢]hdu 2107
摘要:2011-12-15 02:11:52地址:http://acm.hdu.edu.cn/showproblem.php?pid=2107题意:中文,找最大。代码:# include <stdio.h>int main (){ int n, a, max ; while (~scanf ("%d", &n)) { if (n == 0) break ; scanf ("%d", &max) ; while (n-- -1) { scanf ("%d", &a) ; if (a >... 阅读全文

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

[恢]hdu 2109
摘要:2011-12-15 02:19:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=2109题意:中文。。废话超多。代码:# include <stdio.h># include <stdlib.h># define REP(i,n) for(i = 0 ; i < n ; i++)int cmp(const void *a, const void *b){ return *(int*)a - *(int*)b ;}int main (){ int n, _1, _2, i; int a[110], b[110] ; w 阅读全文

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

[恢]hdu 2101
摘要:2011-12-15 02:06:24地址:http://acm.hdu.edu.cn/showproblem.php?pid=2101题意:两数和是否是86的倍数。代码:# include <stdio.h>int main (){ int a, b ; while (~scanf ("%d%d", &a, &b)) puts (((a+b)%86) ? "no" : "yes") ; return 0 ;} 阅读全文

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

[恢]hdu 2076
摘要:2011-12-15 01:59:41地址:http://acm.hdu.edu.cn/showproblem.php?pid=2076题意:中文。。。mark:换算有点麻烦,其实无难点。代码:# include <stdio.h># include <math.h>int main (){ int T, h,m,s,a ; double hh, mm ; double arg ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d%d", &h, &m, & 阅读全文

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

[恢]hdu 2055
摘要:2011-12-15 02:03:44地址:http://acm.hdu.edu.cn/showproblem.php?pid=2055题意:字母替换成数字,求和,简单~~代码:# include <stdio.h># include <math.h>int main (){ int T, num ; char ch ; scanf ("%d%*c", &T) ; while (T--) { scanf ("%c %d%*c", &ch, &num) ; if (ch >= 'a' & 阅读全文

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

[恢]hdu 2090
摘要:2011-12-15 01:27:17地址:http://acm.hdu.edu.cn/showproblem.php?pid=2090题意:中文。。mark:输入有点麻烦,用正则居然错了。。。直接用最暴力的方式a了。代码:# include <stdio.h>int main (){ double a, b, sum = 0 ; char s[100] ; while (~scanf ("%s%lf%lf", s, &a, &b)) sum += a*b ; printf ("%.1lf\n", sum) ; return 阅读全文

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

[恢]hdu 1021
摘要:2011-12-15 01:34:16地址:http://acm.hdu.edu.cn/showproblem.php?pid=1021题意:fibonacci变种,f[0] = 7, f[1] = 11。问第n项是否能被3整除。mark:打表看规律,循环节为3,模8后为2或6的则为3的倍数。代码:# include <stdio.h>int main (){ int n ; while (~scanf ("%d", &n)) if (n%8 == 2 || n%8 == 6) puts ("yes") ; else puts (&q 阅读全文

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

[恢]hdu 2099
摘要:2011-12-15 00:37:50地址:http://acm.hdu.edu.cn/showproblem.php?pid=2099题意:中文。。。不说了。代码:# include <stdio.h>int main (){ int i, n, m, flag ; while (~scanf ("%d%d", &n, &m) && (n||m)) { flag = 0 ; for (i = 0 ; i < 100 ; i++) if ((n*100+i) % m == 0) { ... 阅读全文

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

[恢]hdu 2070
摘要:2011-12-15 00:29:10地址:http://acm.hdu.edu.cn/showproblem.php?pid=2070题意:求第n个fibonacci数。mark:注意long long。注意0(不知道有没有)代码:# include <stdio.h># include <math.h>long long dp[55] = {0, 1} ;int main (){ int i, n ; for (i = 2 ; i<= 50 ; i++) dp[i] = dp[i-1]+dp[i-2] ; while (~scanf ("%d&quo 阅读全文

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