上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 51 下一页
摘要: 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 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 2011-12-16 02:11:23地址:http://acm.hdu.edu.cn/showproblem.php?pid=2114题意:算前n项立方和的末4位。mark:立方和公式:n^2(n+1)^2/4。注意取mod和溢出处理。代码:# include <stdio.h>int main (){ long long n ; int ans ; while (~scanf ("%I64d", &n)) { n %= 10000 ; ans = (n*n*(n+1)*(n+1)/4) % 10000 ; printf ("... 阅读全文
posted @ 2012-01-06 16:38 Seraph2012 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 2011-12-16 02:01:14地址:http://acm.hdu.edu.cn/showproblem.php?pid=1465题意:中文。。mark:错拍问题。。。递推。dp[i] = (i-1) * (dp[i-1] + dp[i-2])代码:# include <stdio.h># include <string.h>long long dp[25] = {0, 0, 1} ;int main (){ int i ; for(i = 3 ; i <= 20 ; i++) dp[i] = (i-1)*(dp[i-1]+dp[i-2]) ; while. 阅读全文
posted @ 2012-01-06 16:37 Seraph2012 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 2011-12-16 01:56:14地址:http://acm.hdu.edu.cn/showproblem.php?pid=1860题意:中文。。。直接爆。代码:# include <stdio.h># include <string.h>int main (){ int i, j, tab[10] ; char s1[10], s2[100] ; while (gets(s1)) { if (strcmp(s1, "#") == 0) break ; gets (s2) ; memset (tab, 0, sizeof(t... 阅读全文
posted @ 2012-01-06 16:36 Seraph2012 阅读(146) 评论(0) 推荐(0) 编辑
上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 51 下一页