andre_joy

导航

随笔分类 -  HDOJ

上一页 1 2 3 4 5 6 下一页

hdu 2602
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2602题意:背包问题。mark:第一次背包~代码:#include <stdio.h>#include <string.h>int v[1010],c[1010];int dp[1010];int max(int a, int b) {return a > b ? a : b;}int main(){ int t,m,n; int i,j; scanf("%d", &t); while(t-- && scanf("%d% 阅读全文

posted @ 2012-07-23 16:29 andre_joy 阅读(113) 评论(0) 推荐(0)

hdu 4301
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=4301题意:分巧克力,注意每块巧克力都不一样。mark:dp,三维的。代码:#include <stdio.h>int dp[1010][2010][2];int main(){ int t,i,j; dp[1][1][0] = dp[1][2][1] = dp[2][1][0] = dp[2][3][0] = dp[2][4][1] = 1; dp[2][2][0] = dp[2][3][1] = 3; dp[2][2][1] = 3; for(i = 3; i <= 1... 阅读全文

posted @ 2012-07-20 09:17 andre_joy 阅读(185) 评论(0) 推荐(0)

hdu 4302
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=4302题意:虫子吃蛋糕,总是吃最近的,如果一样近,按之前顺序吃。mark:wa了无数次啊,,最后终于找到错误了,队列没有清空。。。 第一次用这种queue的库函数写,比较生涩,不过最后ac了,挺高兴的~代码:#include <queue>#include <iostream>#define LL __int64using namespace std;struct cmp{ bool operator()(LL a, LL b) { return a > b; }}... 阅读全文

posted @ 2012-07-19 23:01 andre_joy 阅读(236) 评论(0) 推荐(0)

hdu 1015
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1015题意:找符合题目给定公式字典序最后的字符串。mark:暴力过……代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int n,c[15];char a[15], b[30] = "1ABCDEFGHIJKLMNOPQRSTUVWXYZ";int cmp(const void *a, const void *b){ return *(int *)b - *(int *)a;}v 阅读全文

posted @ 2012-07-18 10:43 andre_joy 阅读(361) 评论(0) 推荐(0)

hdu 1166
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1166题意:中文……mark:线段树。第一次写线段树,目的是减小空间复杂度。代码:#include <stdio.h>#define LL(x) ((x) << 1)#define RR(x) ((x) << 1 | 1)typedef struct{ int le,ri,mi,su;}tree;int a[50010];tree t[150000];int build(int l, int r, int s){ t[s].le = l; t[s].ri = r; t 阅读全文

posted @ 2012-07-13 21:14 andre_joy 阅读(114) 评论(0) 推荐(0)

hdu 1856
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1856题意:找一组的最大人数。mark:并查集,注意最后搜索的细节。虽然wa了很多次,但是ac了还是很爽的。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int a[200010], b[200010], c[200010][2], d[100010];int j;int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b 阅读全文

posted @ 2012-07-13 17:39 andre_joy 阅读(128) 评论(0) 推荐(0)

hdu 1232
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1232题意:中文……mark:并查集。代码:#include <stdio.h>int s[1010];int find(int a){ if(s[a] == a) return a; return s[a] = find(s[a]);}void merge(int a, int b){ int p = find(a), q = find(b); if(p != q) s[p] = q;}int main(){ int n,m,a,b; int i,sum; w... 阅读全文

posted @ 2012-07-13 13:58 andre_joy 阅读(167) 评论(0) 推荐(0)

hdu 1253
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1253题意:中文……mark:bfs,wa了无数次啊,,细节处理的不好,没注意走不出去的情况。可能有两种,第一种根本无法走到门,第二种门本来就是死路。代码:#include <stdio.h>#include <string.h>int s[130000][3],d[50][50][50],h[50][50][50],a,b,c,t;void bfs(){ int front = 0, rear = 1; int aa,bb,cc,aaa,bbb,ccc,i; int tab[6 阅读全文

posted @ 2012-07-13 11:48 andre_joy 阅读(196) 评论(0) 推荐(0)

hdu 1372
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1372题意:按照国际象棋规则马最少几步从开始点走到终点。mark:bfs,仔细。代码:#include <stdio.h>#include <string.h>int a[100][2],d[8][8];char p[5],q[5];void bfs(){ int front = 0,rear = 1,m,n; d[p[0]-'a'][p[1]-'0'-1] = 0; a[0][0] = p[0]-'a'; a[0][1] = p[ 阅读全文

posted @ 2012-07-12 22:40 andre_joy 阅读(290) 评论(0) 推荐(0)

hdu 2717
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2717题意:三种走法+1,-1,*2,最少几步到指定点。mark:wa了好多次。bfs算法,注意临界条件。代码:#include <stdio.h>#include <string.h>int a[100010],d[100010],n,k;void bfs(){ int front = 0,rear = 1,nn; a[0] = n; d[n] = 0; while(front != rear) { nn = a[front++]; if(nn... 阅读全文

posted @ 2012-07-12 22:08 andre_joy 阅读(198) 评论(0) 推荐(0)

hdu 1241
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1241题意:跟2952一样,只不过多加了四个方向。mark:多加了四个方向之后,遍历的时候不用打表了,可以直接枚举。代码:#include <stdio.h>char a[110][110];int m,n;void ss(int x, int y){ int i,j,xx,yy; a[x][y] = '1'; for(i = -1; i < 2; i++) for(j = -1; j < 2; j++) { xx = x+i; ... 阅读全文

posted @ 2012-07-12 18:25 andre_joy 阅读(232) 评论(0) 推荐(0)

hdu 2952
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2952题意:找分开的#最多的片数mark:dfs.同1312一样。代码:#include <stdio.h>char a[110][110];int h,w;void ss(int x, int y){ int tab[4][2] = {0,1,0,-1,-1,0,1,0}; int i,xx,yy; a[x][y] = '1'; for(i = 0; i < 4; i++) { xx = x+tab[i][0]; yy = y+tab[i][1... 阅读全文

posted @ 2012-07-12 18:04 andre_joy 阅读(159) 评论(0) 推荐(0)

hdu 1312
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1312题意:找可以到达的黑格子。mark:dfs..代码:#include <stdio.h>char a[25][25];int sum;void ss(int w, int h, int x, int y){ if(y > 0 && a[x][y-1] == '.') { a[x][y-1] = '1'; sum++; ss(w, h, x, y-1); } if(x < h-1 && a[x+1][y] == 阅读全文

posted @ 2012-07-12 17:48 andre_joy 阅读(136) 评论(0) 推荐(0)

hdu 2189
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2189题意:中文……mark:母函数求解。参见http://baike.baidu.com/view/2415279.htm代码:#include <stdio.h>#include <string.h>int a[35] = {2, 3, 5}, b[2][151];int pd(int m){ int i; for(i = 0; a[i]*a[i] <= m; i++) if(m%a[i] == 0) return 0; return 1;}int main(){ .. 阅读全文

posted @ 2012-07-12 00:02 andre_joy 阅读(182) 评论(0) 推荐(0)

hdu 2117
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=2117题意:找1/n小数点后第m位数字。mark:wa了一次。。没考虑n = 1的情况。。。代码:#include <stdio.h>int main(){ int n,m; int i,re; while(~scanf("%d%d", &n, &m)) { if(n == 1) {printf("0\n");continue;} re = 10; for(i = 1; i < m; i++) re = (re%n)... 阅读全文

posted @ 2012-07-11 22:30 andre_joy 阅读(100) 评论(0) 推荐(0)

hdu 1390
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1390题意:求n转换成2进制后1的位置。mark:代码:#include <stdio.h>int main(){ int d,n,i,f; scanf("%d", &d); while(d-- && scanf("%d", &n)) { i = f = 0; while(n) { if(n & 1) { if(f) printf(" "); ... 阅读全文

posted @ 2012-07-11 17:56 andre_joy 阅读(89) 评论(0) 推荐(0)

hdu 1042
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1042题意:求n!,注意:0 <= n <= 10000,n = 10000时,长度为35660位。mark:用数组的方式存放。代码:#include <stdio.h>#define MOD 10000int a[10010];int main(){ int n,f,s; int i,j; while(~scanf("%d", &n)) { if(n < 2) {printf("1\n");continue;} a[0] = 阅读全文

posted @ 2012-07-11 17:26 andre_joy 阅读(114) 评论(0) 推荐(0)

hdu 1517
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1517题意:从1开始,每个人选择乘2~9中的一个数,谁先大于等于n谁赢。mark:博弈问题。用逆推的思想。比如n = 1000。那么[999,112]是必败区间,再退一步[111,56]是必胜区间,以此类推……代码:#include <stdio.h>int main(){ long long n,p; int i; while(~scanf("%I64d", &n)) { if(n == 1) { puts("Stan wins... 阅读全文

posted @ 2012-07-11 15:36 andre_joy 阅读(123) 评论(0) 推荐(0)

hdu 1849
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1849题意:中文……mark:跟1850一样,还是Nim游戏,参见http://baike.baidu.com/view/1101962.htm代码:#include <stdio.h>int main(){ int m,n,a; while(scanf("%d", &m), m) { n = 0; while(m-- && scanf("%d", &a)) n ^= a; puts(n ? "Rabbit W 阅读全文

posted @ 2012-07-11 14:49 andre_joy 阅读(206) 评论(0) 推荐(0)

hdu 1846
摘要:地址:http://acm.hdu.edu.cn/showproblem.php?pid=1846题意:中文……mark:简单博弈。代码:#include <stdio.h>int main(){ int c,m,n; scanf("%d", &c); while(c-- && scanf("%d%d", &m, &n)) puts(m%(n+1) ? "first" : "second"); return 0;} 阅读全文

posted @ 2012-07-11 13:07 andre_joy 阅读(94) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 下一页