上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 51 下一页
摘要: 2011-12-27 16:05:53地址:http://acm.hdu.edu.cn/showproblem.php?pid=1329题意:有n个棍子,依序从1开始放小球,两个相邻的球编号和必须是完全平方数。求最后一个能放下的序号。mark:最多才1300,直接模拟。代码:# include <stdio.h># include <string.h># include <math.h>int n ;int dp[55] ;int issquare(int a){ int b = sqrt(1.0*a) ; return b*b == a ;}int gao 阅读全文
posted @ 2012-01-06 23:57 Seraph2012 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 15:02:12地址:http://acm.hdu.edu.cn/showproblem.php?pid=1267题意:中文。刚开始没看懂,注意“总”字。代码:# include <stdio.h>long long dp[21][21] ;int main (){ int i, j, m, n ; for (i = 0 ; i <= 20 ; i++) dp[0][i] = 1 ; for (i = 1 ; i <= 20 ; i++) for (j = i ; j <= 20 ; j++) dp[i]... 阅读全文
posted @ 2012-01-06 23:56 Seraph2012 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 15:16:26地址:http://acm.hdu.edu.cn/showproblem.php?pid=1287题意:这题的题意很让人莫名。其实是说存在一个大写字母x,然后让原文(都是大写字母)和x做xor后得到密文。现在给密文求原文。因为x不知道,所以枚举x。判断方法是判断是否解密出来的原文都在'A'-'Z'范围内。代码:# include <stdio.h>int num[10010] ;int n ;int test (int x){ int i ; for (i = 0 ; i < n ; i++) if ((n 阅读全文
posted @ 2012-01-06 23:56 Seraph2012 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 14:25:01地址:http://acm.hdu.edu.cn/showproblem.php?pid=1220题意:一个n*n*n的立方体,被切割成1*1*1的小块。两两配对,问两块公共点不超过2的对数。mark:先算出总对数,减去共面的对数。顶点8个,每个共面3对,棱12条,每条有n-2个方块,每个方块共面4对,非顶点非楞的面上小方块,每个共面5对,一共6个面,每个面有(n-2)^2个这样的小方块。剩下的内部小方块每个共面6对。最后总共面数要除以2,因为每对算了2次。代码:# include <stdio.h>int calc (int n){ int 阅读全文
posted @ 2012-01-06 23:55 Seraph2012 阅读(197) 评论(1) 推荐(0) 编辑
摘要: 2011-12-27 13:44:49地址:http://acm.hdu.edu.cn/showproblem.php?pid=1862题意:中文,排序。代码:# include <stdio.h># include <stdlib.h># include <string.h>typedef struct student{ char num[7] ; char name[9] ; int grade ;}student ;student stu[100010] ;int cmp1(const void *a, const void *b){ student 阅读全文
posted @ 2012-01-06 23:54 Seraph2012 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 14:03:37地址:http://acm.hdu.edu.cn/showproblem.php?pid=1165题意:模拟图中给出的函数计算。mark:直接记忆化肯定会爆栈。写几行就发现,m=0,1,2的规律了。m=3的时候直接爆。代码:# include <stdio.h>int mem[25] = {5, 13} ;int A(int m, int n){ if (m == 0) return n+1 ; if (m == 1) return n+2 ; if (m == 2) return n*2+3 ; if (mem[n] != 0) ... 阅读全文
posted @ 2012-01-06 23:54 Seraph2012 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 13:30:48地址:http://acm.hdu.edu.cn/showproblem.php?pid=1015题意:在给定字符集中选5个字符(v,w,x,y,z)使得满足v - w^2 + x^3 - y^4 + z^5 = target。输出字典序最大的一个。mark:dfs。1WA。一开始以为是字符集中序数最大的(被case2误导了)。先给字符串排一下序就好了。代码:# include <stdio.h># include <string.h># include <stdlib.h>char ans[10] ;int visit 阅读全文
posted @ 2012-01-06 23:53 Seraph2012 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 12:28:09地址:http://acm.hdu.edu.cn/showproblem.php?pid=1027题意:求n个数的第m个排列。mark:最简单快捷有效的方法当然是用next_permutation,但是为了锻炼代码能力还是自己写一下。用flag标记已经选过不能选的数字,find用来查找最小的第num个数字。因为m最多只有10000, 所以当n大于8的时候不需要考虑,直接输出最小的数,递归处理。代码:# include <stdio.h># include <string.h>int flag[1010] ;int label ;in 阅读全文
posted @ 2012-01-06 23:52 Seraph2012 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 12:56:41地址:http://acm.hdu.edu.cn/showproblem.php?pid=1016题意:输入n,输出满足条件的1开头的n个数的排列。条件是相邻两个元素和为素数,而且首尾和为素数。mark:直接dfs。其实非1奇数的情况不存在解。因为总有2个加起来是偶数。代码:# include <stdio.h>int num[25] = {1} ;int visited[25] = {0, 1} ;int n ;int isprime (int n){ // 0 1 2 3 4 5 6 7 8 9 in... 阅读全文
posted @ 2012-01-06 23:52 Seraph2012 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 2011-12-27 05:21:34地址:http://acm.hdu.edu.cn/showproblem.php?pid=1029题意:给n(奇数)个数字,求哪个数出现了至少(n+1)/2次。mark:利用hash。代码:# include <stdio.h># include <string.h># define MOD 999997int tab[MOD][2] ;int ans, max_num ;int hash(int num){ int idx = num % MOD ; while (tab[idx][1] != num && tab 阅读全文
posted @ 2012-01-06 23:51 Seraph2012 阅读(175) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 51 下一页