上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 51 下一页
摘要: 2011-12-20 03:35:04地址:http://acm.hdu.edu.cn/showproblem.php?pid=2088题意:有n堆砖头,分别有a[i]块砖。问至少要移动多少块,能让他们全都一样高。mark:先求平均高度,然后逐个求差后,除以2。代码:# include <stdio.h>int a[60] ;int abs(int n){return n<0?-n:n;}int main (){ int n, i, sum, ans, nCase = 1 ; while (~scanf ("%d", &n) && 阅读全文
posted @ 2012-01-06 22:39 Seraph2012 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 2011-12-20 03:41:50地址:http://acm.hdu.edu.cn/showproblem.php?pid=2393题意:输入三角形三边长,判断是否是直角三角形。mark:勾股定理,最大边40000,运算中间数最大是3.2*10^9,比int的上界2.2*10^10小,因此不用担心溢出。代码:# include <stdio.h>int main (){ int T, a, b, c ; int nCase = 1 ; scanf ("%d", &T) ; while (T--) { scanf ("%d%d%d" 阅读全文
posted @ 2012-01-06 22:39 Seraph2012 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 2011-12-20 03:27:09地址:http://acm.hdu.edu.cn/showproblem.php?pid=2087题意:中文。直接枚举。代码:# include <stdio.h># include <string.h>char s1[1010], s2[1010] ;int find(char *s1, char *s2){ int i ; for (i = 0 ; s2[i] ; i++) if (s1[i] != s2[i]) return 0 ; return 1 ;}int main (){ int i, len1, len... 阅读全文
posted @ 2012-01-06 22:38 Seraph2012 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 2011-12-20 03:18:52地址:http://acm.hdu.edu.cn/showproblem.php?pid=2058题意:找[a,b]连续和为m的数串。枚举a或者枚举b都是会超时的,只能枚举a到b的项数。因为这个数字的范围是1到sqrt(8b)左右,因此不会TLE。TLE了2次,都是2b错误。第一次直接枚举a,第二次忘了考虑a了,直接枚举了所有的情况- -。代码:# include <stdio.h># include <math.h>void output (long long a, long long b){ long long n, p ; f 阅读全文
posted @ 2012-01-06 22:36 Seraph2012 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 2011-12-20 02:48:53地址:http://acm.hdu.edu.cn/showproblem.php?pid=2043题意:中文。代码:# include <stdio.h>char str[60] ;int test (char str[]){ int i, flag[4] = {0,0,0,0} ; for (i = 0 ; str[i] ; i++) { if (str[i] >= 'A' && str[i] <= 'Z') flag[0] = 1 ; else if (str[i] >= & 阅读全文
posted @ 2012-01-06 22:35 Seraph2012 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 2011-12-20 02:53:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2057题意:十六进制a+b~代码:# include <stdio.h>int main (){ long long a, b, c ; while (~scanf ("%I64X%I64X", &a, &b)) { c = a+b ; if (c < 0){putchar ('-') ; c = -c ;} printf ("%I64X\n", c) ; } return 0 阅读全文
posted @ 2012-01-06 22:35 Seraph2012 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 2011-12-20 02:42:35地址:http://acm.hdu.edu.cn/showproblem.php?pid=1085题意:面额为1、2、5的硬币各有a、b、c枚。问最小的不能由它们组成的面额。mark:不要想复杂了。对于一个给定的面额n,可以用O(1)的贪心办法判断它是否能由题目所给条件的硬币组成。然后从头搜到尾。代码:# include <stdio.h>int a, b, c ;int min(int a, int b){return a<b?a:b;}int test(int n){ n -= 5*min(n/5, c) ; n -= 2*min(n 阅读全文
posted @ 2012-01-06 22:30 Seraph2012 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 2011-12-19 17:24:45地址:http://acm.hdu.edu.cn/showproblem.php?pid=1234题意:每天有n个人签到和离开,问最早到的和最后离开的人的名字。水。代码:# include <stdio.h># include <string.h>typedef struct tm{ int h, m, s ;}tm ;int isless(tm t1, tm t2){ if (t1.h != t2.h) return t1.h < t2.h ; if (t1.m != t2.m) return t1.m < t2.m 阅读全文
posted @ 2012-01-06 22:26 Seraph2012 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 2011-12-19 02:42:34地址:http://acm.hdu.edu.cn/showproblem.php?pid=1051题意:有n个木棍长为l重为w。机器处理木棍,若前一根的l和w均不小于后一根,则不需要额外时间,否则需要额外时间1。问最小需要多少时间。mark:网上说是贪心,想了很久想不明白,画了一下sample1的图(l当做x,w当做y描点),恍然大悟。把所有元素按l从大到小排序后,其实就是导弹拦截系统的问题,求一个LIS(关于最少导弹拦截数等于最长非降子序列长度的证明,因为之前和其他同学讨论过,所以知道挺麻烦的。讨论了两天才勉强证出来,还很不简洁,不过这个结论还是对的)。 阅读全文
posted @ 2012-01-06 22:25 Seraph2012 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 2011-12-19 08:22:18地址:http://acm.hdu.edu.cn/showproblem.php?pid=1789题意:n个作业,第i个作业有个deadline[i],过了deadline才完成需要罚score[i]分。每个作业完成需要1天。问最少要被扣多少分。mark:贪心orDP,that's a problem。想dp没YY出来。看了别人的思路,贪心水过。代码:# include <stdio.h># include <stdlib.h># include <string.h>typedef struct node{ in 阅读全文
posted @ 2012-01-06 22:25 Seraph2012 阅读(247) 评论(0) 推荐(0) 编辑
上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 51 下一页