摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1708题意:给两个字符串s0和s1,sn是sn-1和sn-2拼接而成的。问sn中每个字母出现的次数。mark:直接递推就可以了。注意0的情况。代码:# include <stdio.h># include <stdlib.h># include <string.h>int t1[30], t2[30], t3[30] ;void output (int t[]){ int i ; for (i = 0 ; i < 26 ; i++) printf (" 阅读全文
posted @ 2012-01-07 21:50 Seraph2012 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2309题意:给n个数,去掉一个最大的和一个最小的,然后求平均数。蛋疼的日式英文。代码:# include <stdio.h>int main (){ int n, max_n, min_n, num, sum ; int i ; while (~scanf ("%d", &n), n) { sum = 0 ; min_n = 1100, max_n = -1 ; for (i = 0 ; i < n ; i++) { ... 阅读全文
posted @ 2012-01-07 00:38 Seraph2012 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 2012-01-02 19:55:02地址:http://acm.hdu.edu.cn/showproblem.php?pid=2401题意:有1-N一共N个篮子,每个里面有很多金币。每个金币的重量是w,但是其中有一个篮子金币的重量只有w-d。现在从第一个篮子拿1个金币,第二个拿2个。。。第n-1个篮子拿n-1个。第n个不拿。把拿出来的金币称重。问金币轻的篮子编号是多少。mark:不知道第二组sample为什么可以是10。。。诡异。代码:# include <stdio.h>int main (){ int n, w, d, rst, ans ; while (~scanf (&q 阅读全文
posted @ 2012-01-07 00:37 Seraph2012 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 2012-01-02 17:22:53地址:http://acm.hdu.edu.cn/showproblem.php?pid=2529题意:中文。mark:设v的水平分量为x,则最终距离和x的关系应该是先增后减,遂三分。。。代码:# include <stdio.h># include <math.h>double l, v ;double f(double x){ return sqrt(v*v-x*x)*l/x - 0.5*9.8*l*l/(x*x) ;}int main (){ double left, right, m1, m2, h ; while (~sc 阅读全文
posted @ 2012-01-07 00:36 Seraph2012 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 2012-01-02 04:07:41地址:http://acm.hdu.edu.cn/showproblem.php?pid=2516题意:中文。mark:完全不会。看了网上说打表看出规律似乎是Fibonacci。遂写代码。wa了一次,因为[0...43]的数量我用二分的时候居然算成了43个。。。应该是44个的。代码:# include <stdio.h># include <stdlib.h>int dp[50] = {2, 3} ;int cmp(const void *a, const void *b){ return *(int*)a - *(int*)b ; 阅读全文
posted @ 2012-01-07 00:35 Seraph2012 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 20:47:45地址:http://acm.hdu.edu.cn/showproblem.php?pid=2512题意:中文。。。mark:递推。dp[i][j]表示i张卡片分在j本书的种类数,有dp[i][j] = dp[i-1][j-1] + dp[i-1][j]*j。代码:# include <stdio.h># define MOD 1000int dp[2010][2010] ;int ans[2010] = {0, 1} ;int main (){ int T, n ; int i, j ; dp[1][1] = 1 ; for (i ... 阅读全文
posted @ 2012-01-07 00:34 Seraph2012 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 19:37:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=2539题意:中文。有点点麻烦的模拟。代码:# include <stdio.h># include <string.h>char str[110] ;int goal[20] ;int judge (char s[]){ int len = strlen(s) ; if (len < 10) return 1 ; if (s[len-8] == ' ' && s[len-7] == 'n' 阅读全文
posted @ 2012-01-07 00:33 Seraph2012 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 20:09:16地址:http://acm.hdu.edu.cn/showproblem.php?pid=2511题意:中文。mark:递归。代码:# include <stdio.h>void gao(long long n, long long time, int s, int e){ int m = 6-s-e ; long long mid = (1LL<<(n-1)) ; if (time == mid) { printf ("%I64d %d %d\n", n, s, e) ; return ; } ... 阅读全文
posted @ 2012-01-07 00:33 Seraph2012 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 19:19:52地址:http://acm.hdu.edu.cn/showproblem.php?pid=2565题意:中文,模拟。代码:# include <stdio.h># include <string.h>char graph[100] ;void output (int n){ int i ; memset (graph, ' ', sizeof (graph)) ; for (i = 0 ; i < n ; i++) { memset(graph, ' ', sizeof(graph)) ; gr 阅读全文
posted @ 2012-01-07 00:28 Seraph2012 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 19:02:16地址:http://acm.hdu.edu.cn/showproblem.php?pid=2561题意:中文。mark:可以排序,不过也可以扫一遍。用a记录最小值,b记录次小值,更新。代码:# include <stdio.h>int main (){ int T, a, b, i, n, num ; scanf ("%d", &T) ; while (T--) { scanf ("%d", &n) ; a = b = 1000 ; for (i = 0 ; i < n ; i++) 阅读全文
posted @ 2012-01-07 00:27 Seraph2012 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 19:13:38地址:http://acm.hdu.edu.cn/showproblem.php?pid=2566题意:中文。。。mark:题目没给数据范围,实在蛋疼,水了一下。考虑到如果有n个硬币,全都是1或2,能组成[n,2n]区间内任何一个数。所以枚举面额为5的硬币个数,然后计算剩下的面额是否在剩下的1、2硬币组成的面额区间内。15ms。那个dp[]数组没用,一开始看错题了。代码:# include <stdio.h>int dp[] = {1, 1, 2, 3, 5, 9} ;int main (){ int T, i, n, m, nn, mm, a 阅读全文
posted @ 2012-01-07 00:27 Seraph2012 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 18:58:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=2562题意:中文。有点不明确,其实就是第0个和第1个互换,第二个和第三个互换。。。代码:# include <stdio.h>char str[100] ;int main (){ int T, i ; scanf ("%d", &T) ; while (T--) { scanf ("%s%*c", str) ; for (i = 0 ; str[i] ; i+=2) printf ("%c%.. 阅读全文
posted @ 2012-01-07 00:25 Seraph2012 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 18:53:55地址:http://acm.hdu.edu.cn/showproblem.php?pid=2564题意:中文。。。没啥好说的,处理就行了。代码:# include <stdio.h>char str[1000] ;void output(char str[]){ int i ; for(i = 0 ; str[i] ; i++) { if ((i == 0 || str[i-1] == ' ') && str[i] != ' ') putchar (str[i] & 0xDF) ; }}i 阅读全文
posted @ 2012-01-07 00:24 Seraph2012 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 18:44:21地址:http://acm.hdu.edu.cn/showproblem.php?pid=1548题意:有一个奇怪的电梯,只有2个按钮,上和下。第i楼层有一个值Ki。假设在第i层,按上它会向上走Ki层,按下也一样。如果超过n层或少于1层,则原地不动。问从第a层到b层需要几次操作。mark:BFS之。代码:# include <stdio.h># include <string.h>int aa, bb, n ;int k[210] ;int q[210] ;int step[210] ;void bfs(){ int a, fron 阅读全文
posted @ 2012-01-07 00:23 Seraph2012 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 18:20:59地址:http://acm.hdu.edu.cn/showproblem.php?pid=2102题意:中文。。。mark:你大爷的WA+TLE一共11次才AC。做了至少8个小时。一开始以为是要在严格的T时刻到达才可以,考虑了不可回头和可回头两种情况,dfs之,TLE。。。然后加奇偶剪,还是TLE。之后搜了搜,发现时T时刻以内到都可以,然后拍了个BFS。WA。WA了n次以后才发现时空传送是一定要传送的,不是自己选可以传也可以不传的。然后还WA,想是不是真的要在T时刻才能过,然后加了奇偶剪枝(因为回头路的话可以无限延长时间),还WA。最后发现一个trick是 阅读全文
posted @ 2012-01-07 00:22 Seraph2012 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 10:46:23地址:http://acm.hdu.edu.cn/showproblem.php?pid=1240题意:给n*n*n的三维迷宫,求从起点到终点的最短步数。mark:bfs搞之。注意起点和终点也可以是'X'的情况。代码:# include <stdio.h># include <string.h>char graph[15][15][15] ;int step[15][15][15] ;int q[1010][3] ;int tab[6][3] = { {-1, 0, 0}, {1, 0, 0}, {0, -1,... 阅读全文
posted @ 2012-01-07 00:21 Seraph2012 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 10:01:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=1238题意:给n个字符串,要求找字符串符合该串是所有给出的字符串或给出字符串的反串的子串的。求最大长度。mark:先在输入的时候顺便存储所有串的反串,然后枚举第一个串的所有子串,最后kmp比较。代码:# include <stdio.h># include <string.h>char ss[110][110] ;char sr[110] ;int next[110] = {-1} ;int n ;void getnext(char str[ 阅读全文
posted @ 2012-01-07 00:14 Seraph2012 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 2011-12-31 01:58:02地址:http://acm.hdu.edu.cn/showproblem.php?pid=1239题意:给m、a、b。求一对素数p,q(p<q)使得p*q<=m且p/q >= a/b。若有多对,输出p*q最大的一对。mark:刚开题看了半天,才看明白啥意思。看到m是10w,然后case是2000组,一下懵了,以为不能枚举。后来冷静分析下,其实可以。以下是几个比较重要的结论&分析。1)若m' = p*q,则必不存在另外一对素数p',q'使得m' = p' * q'。2) 若p固定,q要 阅读全文
posted @ 2012-01-07 00:13 Seraph2012 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 2011-12-30 19:52:14地址:http://acm.hdu.edu.cn/showproblem.php?pid=2141题意:给一串ai、bj、ck,一串x,问x是否能表示成ai+bj+ck。mark:不会,搜了一下。把ai+bj存起来。然后二分x-ck。。。复杂度应该是O(500*500 + lg(250000)*500)好极限。代码:# include <stdio.h># include <stdlib.h>int a[510], b[510], c[510] ;int ab[510*510] ;int cmp(const void *a, con 阅读全文
posted @ 2012-01-07 00:12 Seraph2012 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 2011-12-30 19:16:59地址:http://acm.hdu.edu.cn/showproblem.php?pid=2563题意:中文。递推。代码:# include <stdio.h>int dp[25][2] = {1, 0} ;int main (){ int i, n ; for (i = 1 ; i <= 20 ; i++) { dp[i][0] = dp[i-1][0] + dp[i-1][1] ; dp[i][1] = dp[i][0] + dp[i-1][0] ; } scanf ("%d", &n) ; ... 阅读全文
posted @ 2012-01-07 00:11 Seraph2012 阅读(213) 评论(0) 推荐(0) 编辑