随笔分类 -  HDOJ

发布一些HDOJ的做题情况以及代码。
[恢]hdu 2103
摘要:2011-12-15 07:01:39地址:http://acm.hdu.edu.cn/showproblem.php?pid=2103题意:叙述了一个超生罚款的政策。一对夫妇如果生了超过M个小孩,或者已经生有男孩还继续生孩子,罚款。每次罚款的数额是上一次的2倍,一开始是10000。mark:wa了2次,把10000写成了1000,各种2。注意要long long。代码:# include <stdio.h>int main (){ int i, T, m, n ; int flag, num ; long long sum, cur ; scanf ("%d" 阅读全文

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

[恢]hdu 2100
摘要:2011-12-15 06:42:37地址:http://acm.hdu.edu.cn/showproblem.php?pid=2100题意:中文。mark:26进制高精度,没啥好说的。代码:# include <stdio.h># include <string.h>char a[210], b[210] ;int aa[210], bb[210], buff[210] ;void s2n(char *s, int n[]){ int i, len ; n[0] = 1, n[1] = 0 ; while (*s == 'A') s++ ; len = 阅读全文

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

[恢]hdu 2134
摘要:2011-12-15 06:49:09地址:http://acm.hdu.edu.cn/showproblem.php?pid=2134题意:把直径为R的圆平均分为3份,问r1和r2。简单数学。代码:# include <stdio.h># include <math.h>int main (){ int R ; while (~scanf ("%d", &R)) { if (R <= 0) break ; printf ("%.3lf %.3lf\n", R/sqrt(3), R*sqrt(2.0/3.0)) ; 阅读全文

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

[恢]hdu 2031
摘要:2011-12-15 06:24:51地址:http://acm.hdu.edu.cn/showproblem.php?pid=2031题意:中文。。。又见进制转换。代码:# include <stdio.h>void output (int n, int r){ char tab[] = "0123456789ABCDEFGHIJK" ; if (n == 0) return ; output (n/r,r) ; putchar (tab[n%r]) ;}int main (){ int n, r ; while (~scanf ("%d%d&quo 阅读全文

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

[恢]hdu 2023
摘要:2011-12-15 06:08:10地址:http://acm.hdu.edu.cn/showproblem.php?pid=2023题意:中文。。。mark:这题wa了3次!!!脑袋混乱了,把/m和/n写反了。代码:# include <stdio.h>double stu[60], cls[10] ;int a[60][10] ;int main (){ int n, m, i, j, num; while (~scanf ("%d%d", &n, &m)) { for (i = 0 ; i < n ; i++) stu[i] = 0 阅读全文

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

[恢]hdu 2045
摘要:2011-12-15 06:20:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2045题意:中文。mark:递推。wa了1次。没考虑n=3的时候还不满足递推公式,因为n=3的时候,dp[i-2]不存在与首位不同的情况。n=4的时候才开始满足公式dp[i] = dp[i-2]*2 + dp[i-1]。代码:# include <stdio.h>long long dp[55] = {0, 3, 6, 6} ;int main(){ int i, n ; for (i = 4 ; i <= 50 ; i++) dp[i] ... 阅读全文

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

[恢]hdu 1018
摘要:2011-12-15 05:44:21地址:http://acm.hdu.edu.cn/showproblem.php?pid=1018题意:问n!有多少位。mark:网上大部分是斯特林公式。因为n!位数=log10(n!)+1,而log10(n!) = log10(1)+log10(2)+...+log10(n),亦勉强能解。1000ms的题跑900+ms,危险~。代码:# include <stdio.h># include <math.h>/*int calc(int nn){ double n = nn ; double Pi = acos(-1) ; int 阅读全文

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

[恢]hdu 2091
摘要:2011-12-15 05:20:44地址:http://acm.hdu.edu.cn/showproblem.php?pid=2091题意:中文,模拟。mark:2B了,数组开成了50*50。。。wa了2次。代码:# include <stdio.h># include <string.h>char g[50][100] ;int main (){ char ch ; int i, num, a, b ; int flag = 0 ; while (~scanf ("%c", &ch)) { if (ch == '@') b 阅读全文

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

[恢]hdu 2064
摘要:2011-12-15 05:08:51地址:http://acm.hdu.edu.cn/showproblem.php?pid=2064题意:中文。。。mark:递推。dp[i] = dp[i-1]*3+2。代码:# include <stdio.h>long long dp[40] = {0, 2} ;int main (){ int i, n ; for (i = 2 ; i <= 35 ;i ++) dp[i] = dp[i-1]*3 + 2 ; while (~scanf ("%d", &n)) { printf ("%I64d\ 阅读全文

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

[恢]hdu 2056
摘要:2011-12-15 05:02:51地址:http://acm.hdu.edu.cn/showproblem.php?pid=2056题意:给2个矩阵的对角线坐标,求相交面积。计算几何。代码:# include <stdio.h>double max(double a, double b){return a>b?a:b;}double min(double a, double b){return a<b?a:b;}double gao(double a, double b, double c, double d){ double x = max(a,c) ; doub 阅读全文

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

[恢]hdu 1406
摘要:2011-12-15 04:54:11地址:http://acm.hdu.edu.cn/showproblem.php?pid=1406题意:中文,找完数。mark:打表,范围内只有4个完数:6、28、496、8128。代码:# include <stdio.h>int main (){ int i, t, a, b, sum ; int tab[4] = {6, 28, 496, 8128} ; scanf ("%d", &t) ; while (t--) { scanf ("%d%d", &a, &b) ; if 阅读全文

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

[恢]hdu 1877
摘要:2011-12-15 04:45:53地址:http://acm.hdu.edu.cn/showproblem.php?pid=1877题意:中文。又见进制转换。代码:# include <stdio.h>void output(int n, int m){ if (n == 0) return ; output (n/m, m) ; printf ("%d", n%m) ;}int main (){ int m, a, b ; while (~scanf ("%d", &m) && m) { scanf (" 阅读全文

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

[恢]hdu 1870
摘要:2011-12-15 04:41:23地址:http://acm.hdu.edu.cn/showproblem.php?pid=1870题意:中文。。。代码:# include <stdio.h>char str[1010] ;int main (){ int p, i ; while(gets(str)) { p = 0 ; for (i = 0 ; str[i] && str[i] != 'B' ; i++) { if (str[i] == '(') p++ ; else if (str... 阅读全文

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

[恢]hdu 2083
摘要:2011-12-15 04:32:49地址:http://acm.hdu.edu.cn/showproblem.php?pid=2083题意:中文。mark:中位数。代码:# include <stdio.h># include <stdlib.h>int a[510] ;int cmp(const void *a, const void *b){ return *(int*)a - *(int*)b ;}int abs(int n){return n<0?-n:n;}int main (){ int T, n, i, sum ; scanf ("%d& 阅读全文

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

[恢]hdu 2085
摘要:2011-12-15 04:37:17地址:http://acm.hdu.edu.cn/showproblem.php?pid=2085题意:中文。裸递推。代码:# include <stdio.h>long long dp[40][2] = {1, 0} ;int main (){ int i, n ; for (i = 1 ; i<= 33 ; i++) { dp[i][0] = dp[i-1][0]*3 + dp[i-1][1]*2 ; dp[i][1] = dp[i-1][0] + dp[i-1][1] ; } whil... 阅读全文

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

[恢]hdu 2190
摘要:2011-12-15 04:27:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=2190题意:中文。。mark:递推,可以用两种状态搞,也可以直接搞。dp[i] = dp[i-2]*3+dp[i-3]*2。代码:# include <stdio.h>int dp[35] = {1, 1, 3} ;int main (){ int i, n ; for (i = 2 ; i <= 30 ; i++) dp[i] = dp[i-2]*3 + dp[i-3]*2 ; scanf ("%d", &n) ; w 阅读全文

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

[恢]hdu 2067
摘要:2011-12-15 04:19:03地址:http://acm.hdu.edu.cn/showproblem.php?pid=2067题意:中文。。。mark:真心麻烦,二维递推。没用long long导致wa了一次。代码:# include <stdio.h>long long dp[40][40] ;int main (){ int nCase = 1, n ; dp[0][0] = 1 ; int i, j ; for (i = 1 ; i <= 35 ; i++) { dp[i][0] = 1 ; for (j = 1 ; j... 阅读全文

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

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

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

[恢]hdu 2504
摘要:2011-12-15 03:57:35地址:http://acm.hdu.edu.cn/showproblem.php?pid=2504题意:中文。。。mark:注意有不是2*b的情况——那就是a/b是偶数。代码:# include <stdio.h>int gcd(int a, int b){return a%b?gcd(b,a%b):b ;}int main (){ int n ; int a, b, c ; scanf ("%d", &n) ; while (n--) { scanf ("%d%d", &a, & 阅读全文

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

[恢]hdu 1008
摘要:2011-12-15 03:51:16地址:http://acm.hdu.edu.cn/showproblem.php?pid=1008题意:给一串数字,模拟电梯运行。电梯上一层楼耗费6s,下一层耗费4s,停耗费5s,初始在0,问总时间。mark:模拟。。。代码:# include <stdio.h>int main (){ int n ; int sum, cur, num ; while (~scanf ("%d", &n) && n) { sum = cur = 0 ; while (n--) { ... 阅读全文

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