摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2104这道题看很久啊,意思是n个人围成一个圈,大家玩丢手帕游戏,手帕藏在某一个人的箱子里,Haha来找,每一次他都会跳过m-1个人。问你Haha是不是一定能找到手帕。因为Haha找的次数是无限的,可以永远找下去,所以,只要他能把所有的人都找一遍就一定能找到。但按照他的这种找法,如果n和m不互质的话,不互质就会出现某些人是永远不会找。所以看一下 n和m的最大公约数就行了代码:#include <stdio.h>#include <string.h>#include <stdlib. 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1008这是一道简单题,是一道模拟电梯上下,直接计算就可以了代码:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int main(){ int a[100],n,sum; while(scanf("%d",&n),n) { a[0]=0;sum=0; for(int i=1;i<=n;++i) { scanf("%d&qu 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1049这是一道简单题,其实题目很简单,就是一条虫,每步爬u,休息的时候下滑d,知道虫子爬出n的距离,直接模拟就可以了,不过判断时注意一点,就是最后一步不休息也可以。。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int main(){ int n,u,d,sum,k; while(scanf("%d%d%d",&n,&u, 阅读全文