随笔分类 -  HDOJ

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 24 下一页

发布一些HDOJ的做题情况以及代码。
[恢]hdu 2060
摘要:2011-12-16 05:39:05地址:http://acm.hdu.edu.cn/showproblem.php?pid=2060题意:斯诺克游戏。输入a,b,c表示剩下的球数,p的分数,o的分数。现在p打,假设p一杆清,问p的分数是否追得上o。代码:# include <stdio.h>int calc(int n){ int tab[] = {0, 7, 13, 18, 22, 25, 27} ; if (n <= 6) return tab[n] ; return 8*(n-6) + tab[6] ;}int main (){ int T ; int ... 阅读全文

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

[恢]hdu 2111
摘要:2011-12-16 05:20:42地址:http://acm.hdu.edu.cn/showproblem.php?pid=2111题意:中文,拆分背包,直接贪心。代码:# include <stdio.h># include <stdlib.h>typedef struct node{ int v, p ;}node ;node a[110] ;int min(int a, int b){return a<b?a:b;}int cmp(const void *a, const void *b){ node *p = (node*)a, *q = (node* 阅读全文

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

[恢]hdu 2049
摘要:2011-12-16 05:06:54地址:http://acm.hdu.edu.cn/showproblem.php?pid=2049题意:中文。错排+组合。mark:wa了一次。。。忘记写dp的递推。2B了。代码:# include <stdio.h>long long dp[25] = {0, 0, 1} ;long long c[25][25] ;void init(){ int i, j ; for (i = 3 ; i <= 20 ; i++) dp[i] = (i-1)*(dp[i-1]+dp[i-2]) ; for (i = 0 ; i<=20 ... 阅读全文

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

[恢]hdu 2027
摘要:2011-12-16 04:59:45地址:http://acm.hdu.edu.cn/showproblem.php?pid=2027题意:中文。代码:# include <stdio.h># include <string.h>char str[110] ;int main (){ int i, T, nCase = 1 ; char tabstr[] = "aeiou" ; int tab[300] ; scanf ("%d%*c", &T) ; while (T--) { gets(str) ; memset (t 阅读全文

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

[恢]hdu 2098
摘要:2011-12-16 04:54:26地址:http://acm.hdu.edu.cn/showproblem.php?pid=2098题意:中文,水。直接爆。代码:# include <stdio.h># include <math.h>int IsPrime(int n){ int i, lim = (int)sqrt(n)+1 ; if (n == 2 || n == 3) return 1 ; for (i = 2 ; i <= lim ; i++) if (n % i == 0) return 0 ; return 1 ;}int calc(in... 阅读全文

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

[恢]hdu 2028
摘要:2011-12-16 04:45:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=2028题意:中文。代码:# include <stdio.h>int gcd(int a, int b){return a%b?gcd(b,a%b):b;}int lcm(int a, int b){return a/gcd(a,b)*b;}int main (){ int n, num, ans ; while (~scanf ("%d", &n)) { ans = 1 ; while (n--) { ... 阅读全文

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

[恢]hdu 2503
摘要:2011-12-16 04:48:40地址:http://acm.hdu.edu.cn/showproblem.php?pid=2503题意:中文。水。代码:# include <stdio.h>int gcd(int a, int b){return a%b?gcd(b,a%b):b;}int main (){ int T ; int a, b, c, d, e, f, g ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d%d%d", &a, &b, &c, &a 阅读全文

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

[恢]hdu 2084
摘要:2011-12-16 04:39:01地址:http://acm.hdu.edu.cn/showproblem.php?pid=2084题意:中文~经典dp。代码:# include <stdio.h>int dp[110][110] ;int max(int a, int b){return a>b?a:b;}int main (){ int T, n, i, j ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; for (i = 1 ; i <= n ; 阅读全文

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

[恢]hdu 2025
摘要:2011-12-16 04:43:08地址:http://acm.hdu.edu.cn/showproblem.php?pid=2025题意:中文。mark:wa了一次。pos = 0写成了pos = 1。代码:# include <stdio.h>char str[110] ;int main (){ int i, pos ; while (gets(str)) { pos = 0 ; for(i = 1 ; str[i] ; i++) if (str[i] > str[pos]) pos = i ; for ... 阅读全文

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

[恢]hdu 2161
摘要:2011-12-16 04:34:56地址:http://acm.hdu.edu.cn/showproblem.php?pid=2161题意:判断是不是素数。在这题中2不算素数。mark:数据较小,直接暴。wa了一次,没注意结束条件是n<=0而不是n==0。代码:# include <stdio.h>int test(int n){ int i ; if (n <=2) return 0 ; for (i = 2 ; i < n ; i++) if (n%i == 0) return 0 ; return 1 ;}int main (){ int n... 阅读全文

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

[恢]hdu 2113
摘要:2011-12-16 04:29:08地址:http://acm.hdu.edu.cn/showproblem.php?pid=2113题意:中文。代码:# include <stdio.h>int calc(int n){ int sum = 0 ; while(n) { if ((n&1) == 0) sum += (n%10) ; n/=10 ; } return sum ;}int main (){ int n , flag = 0 ; while (~scanf ("%d", &n)) ... 阅读全文

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

[恢]hdu 2154
摘要:2011-12-16 04:24:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2154题意:中文。mark:简单递推。dp[i] = dp[i-1]+dp[i-2]*2。注意取mod。代码:# include <stdio.h>int dp[1010] = {1, 0} ;int main (){ int i ; for (i = 2 ; i<= 1000 ; i++) dp[i] = (dp[i-1] + dp[i-2]*2) % 10000 ; while (~scanf ("%d", &i) 阅读全文

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

[恢]hdu 2092
摘要:2011-12-16 04:16:12地址:http://acm.hdu.edu.cn/showproblem.php?pid=2092题意:中文。mark:可以搜,但是慢。可以配方后得:若n*n-4*m为完全平方数,有解,否则无解。代码:# include <stdio.h># include <math.h>int test(int n, int m){ int buf = n*n-4*m ; int p = sqrt(n*n-4*m) ; if (buf < 0) return 0 ; return (p*p == n*n-4*m) ;}int main ( 阅读全文

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

[恢]hdu 1019
摘要:2011-12-16 04:10:41地址:http://acm.hdu.edu.cn/showproblem.php?pid=1019题意:求n个数字的最小公倍数。mark:lcm(a,b,c) = lcm(a,lcm(b,c))。wa了一次,没注意lcm先除再乘,溢出了。代码:# include <stdio.h>int gcd(int a, int b){return a%b ? gcd(b,a%b) : b;}int lcm(int a, int b){return a/gcd(a,b)*b;}int gao(int n){ int last = 1, cur ; int 阅读全文

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

[恢]hdu 1290
摘要:2011-12-16 04:00:22地址:http://acm.hdu.edu.cn/showproblem.php?pid=1290题意:中文。mark:递推。也可待定系数搞。dp[i] = dp[i-1]+w[i-1]。w[i-1]表示i条直线能把一个平面分成几部分。w[i] = w[i-1]+i。代码:# include <stdio.h>int dp[1010][2] = {1,1} ;int main (){ int i, n ; for (i = 1 ; i <= 1000 ; i++) { dp[i][0] = dp[i-1][0] + i ; ... 阅读全文

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

[恢]hdu 1201
摘要:2011-12-16 03:49:11地址:http://acm.hdu.edu.cn/showproblem.php?pid=1201题意:中文。代码:# include <stdio.h>int IsLeap(int y){return y%4==0 && y%100!=0 || y%400==0;}int days(int y, int m, int d){ int month[2][13] = { {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, {0, 0, 31, 60, 91,... 阅读全文

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

[恢]hdu 1013
摘要:2011-12-16 03:38:55地址:http://acm.hdu.edu.cn/showproblem.php?pid=1013题意:求数字根。(每个数码相加,若不是单位数,再加。)mark:wa了一次,因为数字很长,可能有900多位,不是int和longlong能处理的。代码:# include <stdio.h># include <string.h>int numroot(char str[]){ int i, ans = 0 ; for (i = 0 ; str[i] ; i++) ans += str[i] -'0' ; return 阅读全文

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

[恢]hdu 1303
摘要:2011-12-16 03:33:05地址:http://acm.hdu.edu.cn/showproblem.php?pid=1303题意:给一串各不相同的数字(2-15个),问其中几个数字满足:这串数字中存在一个数是它的两倍。mark:输入有点怪异。代码:# include <stdio.h>int a[20] ;int ans ;int gao(){ int i, j, n ; int cnt = 0 ; ans = 0 ; while (~scanf ("%d", &n)) { if (n == -1) return 0 ; i... 阅读全文

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

[恢]hdu 1321
摘要:2011-12-16 02:16:43地址:http://acm.hdu.edu.cn/showproblem.php?pid=1321题意:字符串逆序输出- -。代码:# include <stdio.h># include <string.h>char str[100] ;int main (){ int n, i, len ; scanf ("%d%*c", &n) ; while (n--) { gets (str) ; len = strlen(str) ; for (i = len-1; i >= 0 ; i--)p... 阅读全文

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

[恢]hdu 2048
摘要:2011-12-16 02:05:33地址:http://acm.hdu.edu.cn/showproblem.php?pid=2048题意:中文。mark:算错拍概率。7以上不变了- -。。。代码:# include <stdio.h># include <string.h>long long dp[25] = {0, 0, 1} ;long long factorial[25] = {1, 1, 2} ;int main (){ int i ; for(i = 3 ; i <= 20 ; i++) { dp[i] = (i-1)*(dp[i-1]+dp[i-. 阅读全文

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

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 24 下一页