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'
转载 2012-01-07 00:33:00
35阅读
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 ; } ...
转载 2012-01-07 00:33:00
31阅读
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
转载 2012-01-07 00:28:00
25阅读
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++)
转载 2012-01-07 00:27:00
45阅读
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,...
转载 2012-01-07 00:21:00
38阅读
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要
转载 2012-01-07 00:13:00
56阅读
2011-12-30 18:25:02地址:http://acm.hdu.edu.cn/showproblem.php?pid=1597题意:中文。。。mark:要用long long。代码:# include <stdio.h># include <math.h>int main (){ long long n, a ; scanf ("%I64d", &n) ; while (~scanf ("%I64d", &n)) { a = (sqrt(1.0+8.0*n)-1) / 2 ; if (a*(a+1)/2
转载 2012-01-07 00:10:00
37阅读
2011-12-30 16:20:20地址:http://acm.hdu.edu.cn/showproblem.php?pid=2152题意:中文。mark:dp搞起。代码:# include <stdio.h># include <string.h>int dp[110][110] ;int main (){ int n, m, a, b, i, j, k ; while (~scanf ("%d%d", &n, &m)) { memset (dp, 0, sizeof(dp)) ; dp[0][0] = 1 ; for (i =
转载 2012-01-07 00:06:00
34阅读
2011-12-31 10:01:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=1238题
转载 2012-01-07 00:14:00
26阅读
2011-12-29 23:07:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=2317题意:给出不放广告的收入,放广告的收入和广告的花费,问结果。代码:# include <stdio.h>int main (){ int n ; int a, b, c ; scanf ("%d", &n) ; while (n--) { scanf ("%d%d%d", &a, &b, &c); if (b-c > a) puts ("advertise&qu
转载 2012-01-07 00:03:00
23阅读
2011-12-29 13:51:00地址:http://acm.hdu.edu.cn/showproblem.php?pid=2554题意:中文,有点绕但是能看懂,不多说了。mark:着实不会,看了网上的规律觉得好扯淡。n%4的余数是3或0的就是Y,否则是N。。。不知道怎么来的,打表也只能看到前12项,之后就非常慢了。代码(C编译):main(n){while(scanf("%d",&n),n){puts((n+1)&2?"N":"Y");}}打表的程序也贴一下吧:# include <stdio.h>
转载 2012-01-07 00:02:00
28阅读
2011-12-27 15:46:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=1326题意:n个高矮不等的堆。每次可以从一个堆拿一块移动到另一堆。问最少移动多少次能使他们全都相等。mark:好经典的题目,不记得在哪儿看到过不只1次了。每个和平均数的差加起来除以二。代码:# include <stdio.h>int num[60] ;int n ;int abs(int n){return n<0?-n:n;}int main (){ int i, sum ,ans, nCase = 1 ; while (~scanf (&qu
转载 2012-01-06 23:57:00
34阅读
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]...
转载 2012-01-06 23:56:00
34阅读
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
转载 2012-01-06 23:54:00
36阅读
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
转载 2012-01-06 23:53:00
58阅读
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
转载 2012-01-06 23:52:00
34阅读
2011-12-26 12:12:51地址:http://acm.hdu.edu.cn/showproblem.php?pid=1032题意:一个数,如果是奇数,变成3倍+1, 如果是偶数,变成原来的一半, 直到1为止,次数叫做循环长度。给一个范围,问范围内最大循环长度。mark:100w,打表记忆化搜。询问次数不多,直接O(n)扫过就好,如果还严格些可以用RMQ。代码:# include <stdio.h>int dp[1000010] = {0, 1, 2} ;int dfs (long long num){ long long next = ((num&1) ? (n
转载 2012-01-06 23:48:00
28阅读
2011-12-26 10:54:08地址:http://acm.hdu.edu.cn/showproblem.php?pid=1010题意:从S走到D是否存在一条路径(走过的方格不能再走)使得正好用T的时间走完。mark:dfs加奇偶剪枝。代码:# include <stdio.h># include <string.h>int sx, sy, ex, ey ;int n, m, T;char graph[110][110] ;int visited[110][110] ;int dfs (int x, int y, int t){ int i, xx, yy ; i
转载 2012-01-06 23:47:00
38阅读
2011-12-26 09:33:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=1241题意:给map,求'@'的联通片数。mark:注意相邻是指周围8格区域内。循环内套bfs或dfs都可以。代码:# include <stdio.h>char graph[110][110] ;int n, m ;void dfs (int x, int y){ int i, xx, yy ; int tab[8][2] = {-1, -1, -1, 0, -1, 1, 0, -1, 0, 1, ...
转载 2012-01-06 23:46:00
40阅读
  • 1
  • 2
  • 3
  • 4
  • 5