摘要: 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) 编辑