摘要:
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, ... 阅读全文
posted @ 2012-01-06 23:46
Seraph2012
阅读(137)
评论(0)
推荐(0)
摘要:
2011-12-26 09:44:26地址:http://acm.hdu.edu.cn/showproblem.php?pid=1056题意:问1/2+1/3+1/4...+1/n不超过输入的最大n是多少。mark:1wa,注意0.5算1。代码:# include <stdio.h># include <math.h>double tab[300] ;int main (){ int i ; double num ; for (i = 2 ; i <= 280 ; i++) tab[i] = tab[i-1] + 1.0/i ; while (~scanf... 阅读全文
posted @ 2012-01-06 23:46
Seraph2012
阅读(175)
评论(0)
推荐(0)
摘要:
2011-12-26 09:07:10地址:http://acm.hdu.edu.cn/showproblem.php?pid=1302题意:有个蜗牛爬墙。墙高H。一开始每天白天能爬U,晚上滑下来D。之后因为疲劳,每天能爬的高度都比前一天减少U*F%。问何时能离开墙(爬过或跌下来)。mark:直接模拟。代码:# include <stdio.h>int h, u, d, f ;int gao(){ double a = 0, b = u, c = 1.0*f/100.0 * u ; int days = 1 ; while (1) { // printf (... 阅读全文
posted @ 2012-01-06 23:45
Seraph2012
阅读(190)
评论(0)
推荐(0)
摘要:
2011-12-26 09:19:37地址:http://acm.hdu.edu.cn/showproblem.php?pid=1312题意:在铺满红砖和黑砖的房间里,一个人每次只能移动到黑砖,问有多少个砖块是可达的。mark:bfs和dfs都可以。。。数据又很小,才20。代码:# include <stdio.h># include <string.h>int ans, n, m ;char graph[30][30] ;int visited[30][30] ;void dfs(int x, int y){ int xx, yy, i; int tab[4][2] 阅读全文
posted @ 2012-01-06 23:45
Seraph2012
阅读(144)
评论(0)
推荐(0)
摘要:
2011-12-26 00:33:25地址:http://acm.hdu.edu.cn/showproblem.php?pid=1250题意:F[1] = F[2] = F[3] = F[4] = 1。F[n] = F[n-1]+F[n-2]+F[n-3]+F[n-4]。输入n,求F[n]。大数运算。代码:# include <stdio.h>int a[6][2100] ;int buff[2100] ;void add(int x[], int y[]){ int i, *p, *q, cc = 0 ; if (x[0] < y[0]) p = x, q = y ; e. 阅读全文
posted @ 2012-01-06 23:44
Seraph2012
阅读(156)
评论(0)
推荐(0)
摘要:
2011-12-25 19:32:54地址:http://acm.hdu.edu.cn/showproblem.php?pid=1276题意:中文。mark:链表。用的静态的。代码:# include <stdio.h># include <memory.h>int node[5010][2] ;void init (int n){ int i ; for (i = 0 ; i <= n; i++) { node[i][0] = i ; node[i][1] = i+1 ; } node[0][0] = n ; node[n][1... 阅读全文
posted @ 2012-01-06 23:43
Seraph2012
阅读(159)
评论(0)
推荐(0)
摘要:
2011-12-26 00:07:58地址:http://acm.hdu.edu.cn/showproblem.php?pid=1181题意:中文,水。mark:bfs练习。代码:# include <stdio.h># include <string.h>char str[200] ;int graph[30][30] ;int visited[30] ;int q[30] ;int gao(){ int i, ch ; int front = 0, rear = 0 ; q[rear++] = 1 ; while (front != rear) { ... 阅读全文
posted @ 2012-01-06 23:43
Seraph2012
阅读(112)
评论(0)
推荐(0)
摘要:
2011-12-25 15:48:22地址:http://acm.hdu.edu.cn/showproblem.php?pid=1237题意:中文。mark:用递归替代栈。1WA。开始没考虑到1 - 2 + 2的情况。把2+2先算了。。。代码:# include <stdio.h># include <string.h>char str[1010] ;double num[1010] ;char op[1010] ;int cnt ;void getWord (){ double buff = 0 ; int i, flag = 0 ; for (i = 0 ; str 阅读全文
posted @ 2012-01-06 23:42
Seraph2012
阅读(126)
评论(0)
推荐(0)
摘要:
2011-12-25 18:26:30地址:http://acm.hdu.edu.cn/showproblem.php?pid=2116题意:输入K和两个K位带符号二进制数,判断两个数的和有没有溢出。mark:不要用两个数加起来判断溢出,要用max减去一个数,否则会出bug。另外不知道为啥要写小于号才能过,小于等于号不行。代码:# include <stdio.h>long long a, b ;int k ;int test (){ long long max, min ; if (k == 64) max = 0x7fffffffffffffffLL ; else max... 阅读全文
posted @ 2012-01-06 23:42
Seraph2012
阅读(150)
评论(0)
推荐(0)
摘要:
2011-12-25 11:39:37地址:http://acm.hdu.edu.cn/showproblem.php?pid=2206题意:判断一个字符串是否是合法IP。mark:没啥好说的,写就好了。代码:# include <stdio.h>char str[110] ;int test (char str[]){ int i, flag = 0, buff, cnt = 0 ; for (i = 0 ; str[i] ; i++) { if (str[i] != '.' && (str[i] > '9' || str[i 阅读全文
posted @ 2012-01-06 23:41
Seraph2012
阅读(237)
评论(0)
推荐(0)

浙公网安备 33010602011771号