上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 51 下一页
摘要: 2011-12-16 12:11:14地址:http://acm.hdu.edu.cn/showproblem.php?pid=2132题意:求sum[i],定义为:当i是3的倍数时,sum[i] = sum[i-1]+i*i*i,否则sum[i] = sum[i-1] + i。mark:直接打表。TLE了2次,就是不打表直接算的后果。代码:# include <stdio.h>long long dp[100010] ;int main (){ long long n, i ; for (i = 1 ; i<= 100000 ; i++) { if (i%3=... 阅读全文
posted @ 2012-01-06 17:35 Seraph2012 阅读(171) 评论(2) 推荐(1) 编辑
摘要: 2011-12-16 11:37:45地址:http://acm.hdu.edu.cn/showproblem.php?pid=1205题意:中文,不解释。mark:注意用long long。代码:# include <stdio.h>int main (){ int T, n, i ; long long num, sum, max ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; max = -1 ; sum = 0 ; for (i = 0 ; ... 阅读全文
posted @ 2012-01-06 17:34 Seraph2012 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 2011-12-16 11:32:45地址:http://acm.hdu.edu.cn/showproblem.php?pid=1196题意:从最低位保留第一个不为0的二进制1。mark:位运算,n&-n代码:# include <stdio.h>int main (){ int n ; while (~scanf ("%d", &n) && n) { printf ("%d\n", n&-n) ; }} 阅读全文
posted @ 2012-01-06 17:33 Seraph2012 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 2011-12-16 11:24:52地址:http://acm.hdu.edu.cn/showproblem.php?pid=2178题意:中文。mark:二分查找的应用。因为二分的最大次数是log2(n)。所以查询n次最大能查到的数是2^n-1。代码:# include <stdio.h>int main (){ int n; scanf ("%d", &n) ; while (~scanf ("%d", &n)) printf ("%d\n", (1<<n) - 1) ; return 0 阅读全文
posted @ 2012-01-06 17:32 Seraph2012 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 2011-12-16 11:30:41地址:http://acm.hdu.edu.cn/showproblem.php?pid=1164题意:分解素因子。。。代码:# include <stdio.h>int main (){ int i, n, flag ; while (~scanf ("%d", &n)) { flag = 0 ; for (i = 2 ; i< n ; i++) { if (n == 1) break ; while (n % i == 0) {... 阅读全文
posted @ 2012-01-06 17:32 Seraph2012 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 2011-12-16 11:13:43地址:http://acm.hdu.edu.cn/showproblem.php?pid=1157题意:给n个数字(n是奇数)找中位数。mark:wa了一次,被题目坑了。他是多组数据输入的。。。代码:# include <stdio.h># include <stdlib.h>int a[10010] ;int cmp(const void *a, const void *b){ return *(int*)a - *(int*)b ;}int main (){ int i, n ; while (~scanf ("%d& 阅读全文
posted @ 2012-01-06 17:31 Seraph2012 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(121) 评论(0) 推荐(0) 编辑
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 51 下一页