随笔分类 -  HDOJ

发布一些HDOJ的做题情况以及代码。
[恢]hdu 2081
摘要:2011-12-15 00:33:26地址:http://acm.hdu.edu.cn/showproblem.php?pid=2081题意:中文。。。不说了。代码:# include <stdio.h>char str[15] ;int main (){ int n ; scanf ("%d%*c", &n) ; while (gets(str)) printf ("6%s\n", str+6) ; return 0 ;} 阅读全文

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

[恢]hdu 2052
摘要:2011-12-15 00:13:24地址:http://acm.hdu.edu.cn/showproblem.php?pid=2052题意:绘图,绘制n*m的大方框,简单模拟。mark:PE一次,每组后面有空行。代码:# include <stdio.h># include <string.h># define REP(a,b) for(a = 0 ; a < b ; a++)char gp[100][100] ;int main (){ int i, n, m ; while (~scanf ("%d%d", &n, &m) 阅读全文

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

[恢]hdu 2053
摘要:2011-12-15 00:25:42地址:http://acm.hdu.edu.cn/showproblem.php?pid=2053题意:有无限多的电灯排成一列,一开始都是关,操作无限多次,第i次操作会把编号为i和i的倍数的电灯改变状态。问最后第i盏电灯的状态是开还是关。mark:TLE了一次,直接扫约数判奇偶结果TLE了。打表找规律,发现只要是平方数(1、4、9、16……)就是开,否则就是关。代码:# include <stdio.h># include <math.h>int main (){ int i, n, m ; while (~scanf (" 阅读全文

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

[恢]hdu 2050
摘要:2011-12-14 23:54:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=2050题意:中文~mark:这题其实是Knuth老爹的《具体数学》1.2的一个例题。可以直接递推(dp[i] = dp[i-1]+4(i-1)+1),也可以用待定系数法求ax^2+bx+c的系数,总之怎么搞都可以啦。代码:# include <stdio.h>int dp[10010] = {1} ;int main (){ int i ; for (i = 1; i<=10000 ;i ++) dp[i] = dp[i-1] + 4*(i... 阅读全文

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

[恢]hdu 2051
摘要:2011-12-15 00:03:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2051题意:输入十进制n,输出n的二进制。mark:注意n=0的情况。代码:# include <stdio.h>void output(int n){ if (n == 0) return ; output (n>>1) ; putchar ((n&1) + '0') ;}int main (){ int n ; while (~scanf ("%d", &n)) { if (n == 0 阅读全文

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

[恢]hdu 2047
摘要:2011-12-14 20:45:44地址:http://acm.hdu.edu.cn/showproblem.php?pid=2047题意:中文。mark:递推,dp[i] = (dp[i-1]+dp[i-2]) * 2。要用long long代码:# include <stdio.h>long long dp[45] = {1, 3} ;int main (){ int i ; for (i = 2 ; i <= 40 ; i++) dp[i] = (dp[i-1]+dp[i-2]) * 2 ; while (~scanf ("%d", &i) 阅读全文

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

[恢]hdu 2034
摘要:2011-12-14 20:35:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=2034题意:中文。。mark:用了qsort和bsearch,蛮好用的。代码:# include <stdio.h># include <stdlib.h>int cmp(const void *a, const void *b){ return *(int*)a - *(int*)b ;}int a[110], b[110] ;int main (){ int i, cnt, flag ; int n, m ; while (~scanf 阅读全文

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

[恢]hdu 2044
摘要:2011-12-14 20:24:33地址:http://acm.hdu.edu.cn/showproblem.php?pid=2044题意:中文。mark:递推,考虑a和b的差,注意要long long。代码:# include <stdio.h>int main (){ int n, m, i ; long long dp[55] = {1, 1} ; for (i = 2 ; i <= 50 ; i++) dp[i] = dp[i-1]+dp[i-2] ; scanf ("%d", &n) ; while (~scanf ("%d% 阅读全文

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

[恢]hdu 2046
摘要:2011-12-14 06:19:27地址:http://acm.hdu.edu.cn/showproblem.php?pid=2046题意:中文。。。mark:递推,dp[i] = dp[i-1] + dp[i-2]。要用long long代码:# include <stdio.h>long long dp[60] = {0, 1, 2} ;int main (){ int i, n ; for (i = 3 ; i <= 50 ; i++) dp[i] = dp[i-1] + dp[i-2] ; while (~scanf ("%d", &n) 阅读全文

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

[恢]hdu 1002
摘要:2011-12-14 06:08:05地址:http://acm.hdu.edu.cn/showproblem.php?pid=1002题意:a+b,不过是大数的。1000位十进制。mark:大数加法,不是很难写。1Y。代码:# include <stdio.h># include <string.h>char s1[1010], s2[1010], s3[1010] ;int a[1010], b[1010], buff[1010] ;void strtonum (char s[], int num[]){ int i ; num[0] = strlen(s) ; f 阅读全文

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

[恢]hdu 2015
摘要:2011-12-14 05:49:09地址:http://acm.hdu.edu.cn/showproblem.php?pid=2015题意:中文,忒麻烦了。代码:# include <stdio.h>int main (){ int n, m, flag ; int i, sum, cnt ; while (~scanf ("%d%d", &n, &m)) { flag = 0 ; cnt = 0 ; sum = 0 ; for (i = 1 ; i <= n ; i++) { ... 阅读全文

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

[恢]hdu 2035
摘要:2011-12-14 05:37:29地址:http://acm.hdu.edu.cn/showproblem.php?pid=2035题意:中文。。。还用不上快速幂。代码:# include <stdio.h>int main (){ int n, m, mul ; while (~scanf ("%d%d", &n, &m) && (m||n)) { mul = 1 ; while (m--) mul = (mul * n) % 1000 ; printf ("%d\n", mul) ; } return 阅读全文

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

[恢]hdu 2041
摘要:2011-12-14 05:42:17地址:http://acm.hdu.edu.cn/showproblem.php?pid=2041题意:中文递推。mark:dp[i] = dp[i-1] + dp[i-2]。用了long long,最大才102334155,int应该也可。代码:# include <stdio.h>long long dp[50] = {0, 1, 1} ;int main (){ int i, n ; for (i = 3 ; i <= 40 ; i++) dp[i] = dp[i-1]+dp[i-2] ; scanf ("%d" 阅读全文

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

[恢]hdu 2096
摘要:2011-12-14 05:30:17地址:http://acm.hdu.edu.cn/showproblem.php?pid=2096题意:中文。。。代码:# include <stdio.h>int main (){ int n, m ; scanf ("%d", &n) ; while (~scanf ("%d%d", &n, &m)) printf ("%d\n", (n%100 + m%100) % 100) ; return 0 ;} 阅读全文

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

[恢]hdu 2097
摘要:2011-12-14 05:33:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=2097题意:中文,进制转换。代码:# include <stdio.h>int base(int n, int b){ int sum = 0 ; while (n) { sum += n%b ; n /= b ; } return sum ;}int main (){ int n ; while (~scanf ("%d", &n) && n) { if (base(n,10... 阅读全文

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

[恢]hdu 2071
摘要:2011-12-14 05:27:59地址:http://acm.hdu.edu.cn/showproblem.php?pid=2071题意:输出n个数里最大的数字。代码:# include <stdio.h>int main (){ int T, n ; double max, high ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; max = -1 ; while (n--) { scanf ("%lf", &high) ... 阅读全文

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

[恢]hdu 2075
摘要:2011-12-14 05:25:11地址:http://acm.hdu.edu.cn/showproblem.php?pid=2075题意:中文,屌爆了,hdu还有那么简单的题。代码:# include <stdio.h>int main (){ int n, m ; scanf ("%d", &n) ; while (~scanf ("%d%d", &n, &m)) puts (n%m?"NO":"YES") ; return 0 ;} 阅读全文

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

[恢]hdu 1108
摘要:2011-12-14 05:23:09地址:http://acm.hdu.edu.cn/showproblem.php?pid=1108题意:中文,lcm = a*b/gcd。其中lcm是最小公倍数,gcd是最大公约数,欧几里得算法。代码:# include <stdio.h>int gcd(int n,int m){return n%m==0?m:gcd(m,n%m);}int main (){ int n, m ; while (~scanf ("%d%d", &n, &m)) printf ("%d\n", n*m/gc 阅读全文

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

[恢]hdu 2524
摘要:2011-12-14 05:20:24地址:http://acm.hdu.edu.cn/showproblem.php?pid=2524题意:中文。mark:有意思。2个维度分开考虑,结果相乘,用到求和公式,没超过int范围。代码:# include <stdio.h>int main (){ int n, m ; scanf ("%d", &n) ; while (~scanf ("%d%d", &n, &m)) printf ("%d\n", n*(n+1)*m*(m+1)/4) ; retur 阅读全文

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

[恢]hdu 1096
摘要:2011-12-14 05:16:49地址:http://acm.hdu.edu.cn/showproblem.php?pid=1096题意:多组,输入n个数字,输出和。代码:# include <stdio.h>int main (){ int sum, n, num ; int flag = 0 ; scanf ("%d", &n) ; while (~scanf ("%d", &n)) { sum = 0 ; while (n--){ scanf ("%d", &num) ; sum +... 阅读全文

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