随笔分类 -  HDOJ

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

发布一些HDOJ的做题情况以及代码。
[恢]hdu 2156
摘要:2011-12-16 11:22:39地址:http://acm.hdu.edu.cn/showproblem.php?pid=2156题意:中文。mark:想找个O(1)的公式,找不到,mathematica生成的公式里含有调和级数。代码:# include <stdio.h>int main (){ int n, i ; double sum ; while (~scanf ("%d", &n) && n) { sum = n ; for (i = 2 ; i<= n ; i++) sum += 2.0*(n-i+1... 阅读全文

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

[恢]hdu 2164
摘要:2011-12-16 11:07:34地址:http://acm.hdu.edu.cn/showproblem.php?pid=2164题意:给出n组剪刀石头布的局势判断胜负。mark:wa了1次。。。。有一个P打成了小写。代码:# include <stdio.h>int main (){ int T, n, num1, num2 ; char ch1, ch2 ; scanf ("%d%*c", &T) ; while (T--) { scanf ("%d%*c", &n) ; num1 = num2 = 0 ; wh.. 阅读全文

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

[恢]hdu 2135
摘要:2011-12-16 10:51:51地址:http://acm.hdu.edu.cn/showproblem.php?pid=2135题意:给一个graph让顺时针or逆时针旋转若干个90°,然后输出。代码:# include <stdio.h>int n ;char grid[15][15] ;int ABS(int n){return n<0?-n:n;}void r(char a[15][15], char b[15][15]){ int i, j ; char c[15][15] ; for (i = 0 ; i< n ; i++) { for .. 阅读全文

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

[恢]hdu 2149
摘要:2011-12-16 10:58:31地址:http://acm.hdu.edu.cn/showproblem.php?pid=2149题意:中文,博弈。分n>m和n<=m讨论。再根据n%(m+1)得到结果。代码:# include <stdio.h>int main (){ int n, m , p, i ; while (~scanf ("%d%d", &m, &n)) { if (m <= n) { for (i = m ; i <= n ; i++) if (i == m) printf ... 阅读全文

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

[恢]hdu 1219
摘要:2011-12-16 10:33:26地址:http://acm.hdu.edu.cn/showproblem.php?pid=1219题意:统计小写字母出现的次数。代码:# include <stdio.h># include <string.h>char str[100010] ;int tab[300] ;int main (){ int i; while (gets(str)) { memset (tab, 0, sizeof(tab)) ; for (i = 0 ; str[i] ; i++) tab[str[i]... 阅读全文

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

[恢]hdu 1339
摘要:2011-12-16 10:39:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=1339题意:给出n,输出o, p满足n == o*2^p,其中o是奇数。代码:# include <stdio.h>int main (){ int n, p ; scanf ("%d", &n) ; while (~scanf ("%d", &n)) { p = 0 ; while (n % 2 == 0) n/=2, p++ ; printf ("%d %d\n", n, p 阅读全文

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

[恢]hdu 1161
摘要:2011-12-16 10:28:49地址:http://acm.hdu.edu.cn/showproblem.php?pid=1161题意:把大写变成小写后输出。。。代码:# include <stdio.h>int main (){ int ch ; while ((ch = getchar ()) != EOF) { if (ch >= 'A' && ch <= 'Z') putchar (ch -'A' + 'a') ; else putchar (ch) ; } return 0 阅读全文

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

[恢]hdu 1012
摘要:2011-12-16 10:26:02地址:http://acm.hdu.edu.cn/showproblem.php?pid=1012题意:按那个公式输出前9项。。。没有输入。代码:# include <stdio.h>int main (){ int i; double sum = 2.5 ; int fact = 2 ; puts("n e") ; puts ("- -----------") ; puts ("0 1") ; puts ("1 2") ; puts ("2 2.5&qu 阅读全文

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

[恢]hdu 1028
摘要:2011-12-16 08:28:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=1028题意:一个整数n,可以表示为多少种和的形式。mark:dp[i][j]表示和为j且和里面最大的数字不超过i的种类数,有dp[i][j] = dp[i-1][j] + dp[i][j-i]。代码:# include <stdio.h>int dp[130][130] ;int main (){ int i, j, n ; dp[0][0] = 1 ; for (i = 1 ; i <= 120 ; i++) { for (j... 阅读全文

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

[恢]hdu 1048
摘要:2011-12-16 08:04:18地址:http://acm.hdu.edu.cn/showproblem.php?pid=1048题意:解码。。。没啥好说的。代码:# include <stdio.h># include <string.h>char ts[] = "VWXYZABCDEFGHIJKLMNOPQRSTU" ;char str[210] ;void gao(){ int i ; for (i = 0 ; str[i] ; i++) { if (str[i] >= 'A' && str[i] & 阅读全文

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

[恢]hdu 1004
摘要:2011-12-16 08:14:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=1004题意:给出n个字符串,输出出现的最多的那个。代码:# include <stdio.h># include <string.h>typedef struct node{ char name[20] ; int num ;}node ;node a[1010] ;int cnt ;void add(char name[]){ int i ; for (i = 0 ; i < cnt ; i++) { if (0 == ... 阅读全文

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

[恢]hdu 2069
摘要:2011-12-16 07:52:18地址:http://acm.hdu.edu.cn/showproblem.php?pid=2069题意:有1、5、10、25、50一共五种硬币,问取不超过100枚组成n的种类有多少。mark:一开始没看到不超过100枚的条件。这题母函数不好做,直接dp吧。dp[i][j][k]表示用前i种硬币j枚组成面额k的种类数,转移方程是dp[i][j][k] = dp[i-1][j][k] +dp[i][j-1][k-tab[i]]。数据小,各种暴力吧。代码:# include <stdio.h>int dp[5][110][300] ;int ans[ 阅读全文

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

[恢]hdu 1020
摘要:2011-12-16 07:58:56地址:http://acm.hdu.edu.cn/showproblem.php?pid=1020题意:把给的字符串编码,如sample。代码:# include <stdio.h>char str[10010] ;int calc(char s[]){ int i, cnt = 0 ; for (i = 0 ; s[i] ; i++) { if (s[i] != s[0]) break ; cnt++ ; } return cnt ;}int main (){ int T, i, n ; ... 阅读全文

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

[恢]hdu 1398
摘要:2011-12-16 07:23:13地址:http://acm.hdu.edu.cn/showproblem.php?pid=1398题意:有1、4、9、16.。。289种面额的硬币无数枚(平方数),组成面值为n的方法有多少种。mark:典型母函数题,不过dp,直接YY出了递推公式,也不难。代码:# include <stdio.h>int dp[20][350] ;int tab[20] = {0, 1} ;int init(){ int i, j ; for (i = 2 ; i <= 17 ; i++) tab[i] = i*i ; for (i = 0... 阅读全文

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

[恢]hdu 2139
摘要:2011-12-16 07:00:16地址:http://acm.hdu.edu.cn/showproblem.php?pid=2139题意:算平方和的奇数项目。mark:1wa,没用long long。公式是(4*p*p*p+12*p*p+11*p+3)/3。其中2p+1 == n。代码:# include <stdio.h>int main (){ long long n, p ; while (~scanf ("%I64d", &n)) { p = (n-1) / 2 ; printf ("%I64d\n", (4*p*p*p+ 阅读全文

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

[恢]hdu 2188
摘要:2011-12-16 07:07:36地址:http://acm.hdu.edu.cn/showproblem.php?pid=2188题意:中文,博弈。mark:结论是:如果n%(m+1)==0则先手败。代码:# include <stdio.h>int main (){ int T, n, m ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d", &n, &m) ; if (n % (m+1) == 0) puts ("Rabbit") ; else 阅读全文

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

[恢]hdu 2131
摘要:2011-12-16 06:45:55地址:http://acm.hdu.edu.cn/showproblem.php?pid=2131题意:问给的字母在后面单词中出现的比例是多少。注意不区分大小写。代码:# include <stdio.h>char word[210] ;int main (){ char ch ; int i, sum ; while (~scanf ("%c %s%*c", &ch, word)) { sum = 0 ; for (i = 0 ; word[i] ; i++) if ((word[... 阅读全文

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

[恢]hdu 2124
摘要:2011-12-16 06:40:40地址:http://acm.hdu.edu.cn/showproblem.php?pid=2124题意:用n个长度各不相同的方块堵住长度为L的墙。可以锯,问最少需要多少块。mark:简单题,贪心。排序即可。wa了几百次!!!搞了40分钟!!!尼玛没考虑到impossible的时候数组越界啊我日!!!太2了。条件i < n+1 没写。其实还有一个bug,就是n==0的情况。不过ac了,就不鸟它了。网上说要用long long,其实int都可以过的。。。# include <stdio.h># include <stdlib.h> 阅读全文

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

[恢]hdu 2061
摘要:2011-12-16 05:53:55地址:http://acm.hdu.edu.cn/showproblem.php?pid=2061题意:算n个成绩的GPA(不是平均学分绩点,是平均学分成绩)。mark:坑爹,s<60写成了s<=60。另外把%lf改成%d居然会TLE。代码:# include <stdio.h>char name[35] ;int main (){ int T, n, flag, nCase = 1 ; double c, s ; double tc, ts ; scanf ("%d%*c", &T) ; while ( 阅读全文

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

[恢]hdu 1202
摘要:2011-12-16 05:30:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=1202题意:中文,算GPA。mark:wa了2次,pe了1次。没看到”如GPA不存在,输出-1“这个条件。。。代码:# include <stdio.h>double point(double p){ if (p >= 90) return 4 ; if (p >= 80) return 3 ; if (p >= 70) return 2 ; if (p >= 60) return 1 ; return 0 ;}int main 阅读全文

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

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