andre_joy

导航

2012年7月11日

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 阅读(94) 评论(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 阅读(83) 评论(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 阅读(98) 评论(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 阅读(111) 评论(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 阅读(198) 评论(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 阅读(88) 评论(0) 推荐(0) 编辑

hdu 1850

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1850题意:中文……mark:Nim游戏,参见http://baike.baidu.com/view/1101962.htm代码:#include <stdio.h>int main(){ int m,a[110]; int i,n,sum; while(scanf("%d", &m), m) { for(i = n = 0; i < m; i++) { scanf("%d", a+i); n ^= a[i]... 阅读全文

posted @ 2012-07-11 12:43 andre_joy 阅读(100) 评论(0) 推荐(0) 编辑

USACO barn1

摘要: 题意:有很多隔间,部分隔间被奶牛占领,要修墙,连在一起的算一面墙,给定墙的最大面数,问怎么修,才能使其包括所有被奶牛占有的地方都能被包围并且墙的总占地最小。mark:wa了一次,写到最后糊涂了一下。。仔细就好。代码:/*ID: andre_j2LANG: CTASK: barn1*/#include <stdio.h>#include <stdlib.h>int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}main(){ freopen("barn1.in", &q 阅读全文

posted @ 2012-07-11 11:08 andre_joy 阅读(118) 评论(0) 推荐(0) 编辑

hdu 1847

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1847题意:中文……mark:wa了一次,题目看错了,以为是只能按照1,2,4……的顺序来取牌。 数据比较小,博弈问题,在纸上找到规律了,直接暴力破解了。代码:#include <stdio.h>int dp[1001] = {0, 1, 1, 0} ;int main (){ int i, j, n ; for (i = 4; i <= 1000; i++) for (j = 1; j <= i; j<<=1) if (dp[i-j] == 0) ... 阅读全文

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