摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1986题意:按要求把字母或空格字符串扩展成5个01字符表示的字符串以后,缠绕放置在一个r*c的矩阵里。最后一排一排输出。mark:各种wa。后来才发现是输入的问题。当字符串长度为0的时候,我本来用的是scanf的正则输入,结果事实证明不行。。。另外用来放置扩展以后的字符串的字符数组ss一开始忘记清0也wa了一次。代码: 1 # include <stdio.h> 2 # include <string.h> 3 4 5 char str[100] ; // less than 8 阅读全文
posted @ 2012-04-27 23:03 Seraph2012 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1981题意:给长度为n的小写字母字符串,有3种操作:"Q A":输出当前字符串的第A个字符;"S A B":把第A个到第B个字符都加1。a变成b,b变成c,z变成a。。。"R A B":把从A到B的字符串逆转。输出就是Q操作的时候的输出。mark:这题真是tricky。一看8w个字符,先知道直接搞是肯定不行的。后来想了一下也没想到好办法。查了一下,原来可以记录下每次的操作,然后查询的时候根据位置往前循环,因为查找次数少,因而效率比较高。一开始w 阅读全文
posted @ 2012-04-27 09:05 Seraph2012 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1673题意:一条路上有n家商店,给出坐标。某人停车在某点后,要逛完所有商店回到车出。停车地点自选,求最少需要步行多远。mark:唬人,其实就是最大值与最小值差的两倍。代码: 1 # include <stdio.h> 2 3 4 int main () 5 { 6 int T, n, num ; 7 int max, min ; 8 scanf ("%d", &T) ; 9 while (T--)10 {11 scanf ("%d", & 阅读全文
posted @ 2012-04-27 06:36 Seraph2012 阅读(273) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1236题意:中文名。这种排序题已经无力吐槽了。敲错变量tle了一次- -。代码: 1 # include <stdio.h> 2 # include <stdlib.h> 3 # include <string.h> 4 5 6 typedef struct STU{ 7 char name[25] ; 8 int scr ; 9 }STU ;10 11 12 STU stu[1010] ;13 int scr[15] ;14 15 16 int cmp (const 阅读全文
posted @ 2012-04-27 06:32 Seraph2012 阅读(265) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2571题意:中文。mark:水dp。不过边界不太好处理,写成dfs+记忆化比较方便。给2组容易错的数据。应该都输出0。21 2-1 12 1-11代码: 1 # include <stdio.h> 2 3 4 int a[25][1010], vis[25][1010] ; 5 int n, m, INF = 0x0f0f0f0f ; 6 7 8 int max(int a, int b){return a>b?a:b;} 9 10 11 int dfs(int x, int y)12 阅读全文
posted @ 2012-04-27 06:19 Seraph2012 阅读(360) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2570题意:中文。mark:很水的题。体积V都一样,排序后贪心就可以了。各种wa,主要还是浓度计算那儿装逼不想用实数,就用整数绕过去,结果各种想不清楚。代码: 1 # include <stdio.h> 2 # include <stdlib.h> 3 4 5 int p[110] ; 6 7 int cmp(const void *a, const void *b) 8 { 9 return *(int*)a - *(int*) b ;10 }11 12 13 int main 阅读全文
posted @ 2012-04-27 06:04 Seraph2012 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2569题意:中文。mark:水递推。很容易得到方程dp[i] = 2*dp[i-1]+dp[i-2]。不过dp[0] = 3。注意要用long long。代码: 1 # include <stdio.h> 2 3 4 long long dp[45] = {3,3} ; 5 6 7 int main () 8 { 9 int T, n, i ;10 for (i = 2 ; i <= 40 ; i++)11 dp[i] = 2*dp[i-1]+dp[i-2] ;1... 阅读全文
posted @ 2012-04-27 05:45 Seraph2012 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2568题意:中文。mark:看清楚题就好了。就是求二进制表示时1的个数。本来嘛递归直接可以搞,请容我装逼一下用了位运算。。。代码: 1 # include <stdio.h> 2 3 4 int calc(int x){return x?calc(x-(x&-x))+1:0;} 5 6 7 int main () 8 { 9 int T, n ;10 scanf ("%d", &T) ;11 while(T--)12 {13 scanf ("%d 阅读全文
posted @ 2012-04-27 05:33 Seraph2012 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2567题意:中文。没啥好说的。代码: 1 # include <stdio.h> 2 # include <string.h> 3 4 5 int main () 6 { 7 int T, i, len ; 8 char s1[55], s2[55] ; 9 scanf ("%d", &T) ;10 while (T--)11 {12 scanf ("%s%s", s1, s2) ;13 len = strlen(s1) ;14.. 阅读全文
posted @ 2012-04-27 05:28 Seraph2012 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1800题意:士兵要学骑扫帚。每个士兵有一个level,level高的能在同一把扫帚上教level低的怎么骑。一个人最多有一个老师,一个学生。也可以没有。给n个士兵的level值,问最少需要多少扫帚。mark:显然就是找出现次数最多的数字的次数。但因为数字长度多达30个字符,因此long long都存不下,用字符串。wa了一次,忘记处理前导0。代码: 1 # include <stdio.h> 2 # include <string.h> 3 # include <stdli 阅读全文
posted @ 2012-04-27 05:24 Seraph2012 阅读(1097) 评论(0) 推荐(1) 编辑