摘要: 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. 阅读全文
posted @ 2011-08-13 21:05 ○o尐懶錨o 阅读(1186) 评论(1) 推荐(1) 编辑
摘要: 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 阅读全文
posted @ 2011-08-13 20:12 ○o尐懶錨o 阅读(146) 评论(0) 推荐(1) 编辑
摘要: 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, 阅读全文
posted @ 2011-08-13 20:10 ○o尐懶錨o 阅读(244) 评论(0) 推荐(1) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2067这是一道卡特兰数,请看资料:http://baike.baidu.com/view/2499752.htm其实就是应用代码:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int main(){ int m,i,j,t=0; __int64 a[40][40]; while(scanf("%d",&m),m!=-1) { t++; 阅读全文
posted @ 2011-08-12 19:55 ○o尐懶錨o 阅读(398) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2065据说这是一个母函数指数型,可是我看了半天觉得还是没有感觉,觉得还是递推比较好,直接看代码可能不懂,但是推理过程太麻烦。。。就是从n-1个来确定第n个,这样一步一步找到规律代码:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int main(){ __int64 n; int t; int a[23]={0,2,6,20,72,72,56,60,12,92,5 阅读全文
posted @ 2011-08-12 18:06 ○o尐懶錨o 阅读(712) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2072这是我第一次写的c++;当然是参考神牛的,库函数真是太强大了,我觉得一个很长的代码,用了几行代码就搞定了,看来以后要好好学习库函数#include<set>#include<iostream>#include<cstring>using namespace std;int main(){ set <string> st; string s=""; char c; while((c=getchar())!='#') { s 阅读全文
posted @ 2011-08-12 12:27 ○o尐懶錨o 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 首先我们来看这个全局变量:__FILE__它表示文件的完整路径(当然包括文件名在内)也就是说它根据你文件所在的目录不同,有着不同的值;当然,当它用在包行文件中的时候,它的值是包含的路径;然后:我们看这个函数:string dirname ( string path )它是PHP内置函数,它的作用是什么呢,就是返回除了本文件名以外的所在目录,给你举个例子假如你的首页中用到了_FILE_这个变量:(假设你的网页所在目录为:http://localhost/web/index.php),那么:_FILE_的值为http://localhost/web/index.php(一个绝对路径)。而此时dir 阅读全文
posted @ 2011-08-12 11:01 ○o尐懶錨o 阅读(9203) 评论(0) 推荐(1) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2068这是一道错排题,不过有点变形,要把所以的你n/2的情况直接相加就可以了#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>__int64 mm(int x,int y){ __int64 sum=1; for(int i=x;i>=x-y+1;--i) sum*=i; for(int j=y;j>=2;--j) sum/=j; return sum;} 阅读全文
posted @ 2011-08-11 21:10 ○o尐懶錨o 阅读(205) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2045a(1)=3;a(2)=6;a(3)=6;a(4)=18;现在考虑n>3的情况,若第n-1个格子和第一个格子不同,则为a(n-1);若第n-1个格子和第1个格子相同,则第n-2个格子和第一个格子必然不同,此时为a(n-2)再乘第n-1个格子的颜色数,很显然第n-1个格子可以是第一个格子(即第n-2个格子)的颜色外的另外两种,这样为2*a(n-2);#include <stdio.h>#include <string.h>#include <stdlib.h>#i 阅读全文
posted @ 2011-08-11 18:04 ○o尐懶錨o 阅读(227) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2049这是一道错排题,可是比赤裸裸的要多一点东西。因为m个人错排,可是不知道是哪m个错排,所以要用到高中排列组合,即调用函数的公式:代码:#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>__int64 mm(int x,int y){ __int64 sum=1; for(int i=x;i>=x-y+1;--i) sum*=i; for(int j=y;j& 阅读全文
posted @ 2011-08-11 15:51 ○o尐懶錨o 阅读(592) 评论(0) 推荐(0) 编辑