上一页 1 2 3 4 5 6 7 8 9 10 ··· 51 下一页
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2716题意:第一行给出一个字母表的排列。用其解密第二行的文本。代码: 1 # include <stdio.h> 2 3 4 5 int main () 6 { 7 char tab[30], str[100] ; 8 9 int i ;10 while (gets (tab))11 {12 gets (str) ;13 for(i = 0 ; str[i] ; i++)14 {15 ... 阅读全文
posted @ 2012-06-10 11:14 Seraph2012 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2715题意:给一个n,问能表示成几种连续数字的和的形式。mark:很简单,当然是枚举连续数字的个数(从1到sqrt(n))。代码: 1 # include <stdio.h> 2 3 4 int main () 5 { 6 int n, d, ans ; 7 while (~scanf ("%d", &n)) 8 { 9 ans = 0 ;10 for (d = 1 ; d*(d+1) <= 2*n ; d++)11 {12 ... 阅读全文
posted @ 2012-06-10 11:09 Seraph2012 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2714题意:给一串ISBN号,根据算法求出缺的(?表示)那一位。算法是各位上的数字按权相加,和必须为11的倍数。没啥好说的,直接穷举。注意不存在输出-1。代码: 1 # include <stdio.h> 2 3 4 int main () 5 { 6 char str[20] ; 7 int sum, i, pos ; 8 while (gets(str)) 9 {10 sum = 0 ;11 for (i = 0 ; str[i] ... 阅读全文
posted @ 2012-06-10 10:52 Seraph2012 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2711题意:有n个牛排成一列,每个牛有序号(1~n),给出每个牛之前有多少个序号小于当前牛的牛数,求序号。第一头牛的未给出。mark:直接从后往前,每次找小于它但是没被选过的序号有多少个,暴力,效率是O(n^2),200+ms。正解应该是树状数组之类的,懒得写了。代码: 1 # include <stdio.h> 2 # include <string.h> 3 4 5 int dp[8010], ans[8010], a[8010] ; 6 int n ; 7 8 int ma 阅读全文
posted @ 2012-06-10 10:41 Seraph2012 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2710题意:输入n个数,找到最大素因子最大的那个输出。mark:此题实在是坑,1算素数不说,题目是尼玛多组输入的。。。而且我更2,5WA,刚被坑了一个同样的地方,又被坑。。。代码: 1 # include <stdio.h> 2 3 4 int dp[20010] = {0,1} ; 5 6 7 int IsPrime(int x) 8 { 9 int i ;10 for (i = 2 ; i*i <= x ; i++)11 if (x %i == 0) retu... 阅读全文
posted @ 2012-06-10 10:17 Seraph2012 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2709题意:一个整数n,表示为若干个2的幂的数字和,问有多少种(mod 1e9)。mark:递推题,考虑1的个数不同,剩下的都是2的幂,可以除以2转移成更小的状态。得递推方程为dp[i] = dp[i-2] + dp[i/2]。注意初始值。代码: 1 # include <stdio.h> 2 3 4 int tab[1000010] = {1, 1, 2} ; 5 6 7 int main () 8 { 9 int i ;10 for (i = 3 ; i <= 1000000... 阅读全文
posted @ 2012-06-10 10:00 Seraph2012 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2708题意:给4行,统计大写字母的频率,然后按图示输出。mark:此题很坑,主要表现在:1.每行行末的空格不可以输出!2.输入是多组!!!wa了n次。一开始找max_row的时候初始化各种改错。。。代码: 1 # include <stdio.h> 2 # include <string.h> 3 4 5 int tab[300] ; 6 char str[100] ; 7 int max_tab[300] ; 8 9 10 int main ()11 {12 int i, j 阅读全文
posted @ 2012-06-10 09:49 Seraph2012 阅读(303) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1022题意:火车调度问题,栈的基本应用。。。2wa。。。变量忘记初始化。。。太2了。代码: 1 # include <stdio.h> 2 3 4 int n, ans[25] ; 5 char s1[15], s2[15] ; 6 char s[15] ; 7 8 9 int gao()10 {11 int i, p = 0, q = 0, top = 0 ;12 for (i = 0 ; i < 2*n ; i++)13 {14 if (top != ... 阅读全文
posted @ 2012-06-10 09:06 Seraph2012 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1209题意:给5个时间(小时:分钟),将之排序。排序规则是按指针锁夹锐角小到大,若夹角相等则按时间早到晚。最后输出中间的那个时间。mark:题目很简单,角度也很好算:时针每小时走30度,每分钟走0.5度。分针每分钟走6度。做差后取绝对值,再和180比一下,如果大于180,用360减。为了避免浮点数排序的麻烦,可乘以2倍后排序。3WA。。。排序的时候if语句后面手贱多写了一个;查了半天才查出来。。。 1 # include <stdio.h> 2 # include <stdlib.h& 阅读全文
posted @ 2012-06-10 08:37 Seraph2012 阅读(544) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1709题意:给n个砝码的重量,问从1到重量总和中不能称出的重量的个数和分别都是谁。mark:注意新砝码可以加在左盘也可以加在右盘。代码: 1 # include <stdio.h> 2 # include <string.h> 3 4 5 int dp[10010] ; 6 int buff[10010] ; 7 int n ; 8 9 10 int abs(int a){return a<0?-a:a;}11 12 int main ()13 {14 int i, j, 阅读全文
posted @ 2012-05-23 14:39 Seraph2012 阅读(342) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 51 下一页