摘要:
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 (... 阅读全文
摘要:
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] 阅读全文
摘要:
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. 阅读全文
摘要:
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... 阅读全文
摘要:
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) { ... 阅读全文
摘要:
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... 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
2011-12-25 11:17:07地址:http://acm.hdu.edu.cn/showproblem.php?pid=1203题意:中文。。。mark:标准01背包。概率正着不好算,算拿不到的概率就好了。代码:# include <stdio.h>double dp[10010] ;int n, m ;double min(double a, double b){return a<b?a:b;}int main (){ int i, j, cost ; double prob ; while (~scanf ("%d%d", &m, &a 阅读全文
摘要:
2011-12-25 11:25:29地址:http://acm.hdu.edu.cn/showproblem.php?pid=1280题意:输入n个数,输出两两和的前m个。mark:桶排序的经典应用。代码:# include <stdio.h># include <string.h>int tab[10010] ;int a[3010] ;void output (int m){ int i, cnt = 0, flag = 0 ; for (i = 10000 ; i >= 0 ; i --) { while (tab[i]) { ... 阅读全文