上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 42 下一页
摘要: 康托展开是全排列到自然数的双射。x=a[ n ]*( n-1 )!+a[ n-1 ]*( n-2 )!+...+a[ 1 ]*0;a[ i ]:代表着原数列中存在多少个比 第 n-i 个数小的数;例如:3 5 7 4 1 2 9 6 8现在要设置到自然数的双射:对于 3: 存在 1 2比他小,且1 2 没出现过所以 x1 = 2*8!(8是表示除第一位填了1 或2 之后还剩余的空位置)对于 5:存在 1 2 3 4 但是 3 出现过了,所以只有1 2 4所以 x2 = 3*7!(第一位为3,第二位为 1 2 4 中的一个,还剩于7个位置没填数 )对于 7 :存在 1 2 3 4 5 6 但是3 阅读全文
posted @ 2013-03-08 16:36 xxx0624 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 简单dpdp[ i ][ j ]=dp[ i-1 ][ j ](放一个H得到dp[ i ][ j ])+dp[ i ][ j-1 ]( 放一个D得到dp[ i ][ j ]);注意初始化 为dp[ i ][ 0 ]=1;!!!!!!!View Code 1 #include<stdio.h> 2 #include<string.h> 3 const int maxn = 24; 4 typedef __int64 int64; 5 int64 dp[ maxn ][ maxn ]; 6 7 void init(){ 8 for( int i=0;i<=20;i++ 阅读全文
posted @ 2013-03-05 00:30 xxx0624 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 只要注意记录的 0 的个数就行水~~View Code 1 /* 2 字符串逆转 3 */ 4 #include<stdio.h> 5 #include<string.h> 6 #include<stdlib.h> 7 #include<algorithm> 8 #include<iostream> 9 #include<queue>10 //#include<map>11 #include<math.h>12 using namespace std;13 typedef long long ll; 阅读全文
posted @ 2013-03-04 22:10 xxx0624 阅读(354) 评论(0) 推荐(0) 编辑
摘要: n个插座,m个电器,k个适配器。建图:原点s到电器 容量1电器到插座 容量1插座到终点 容量1插座到适配器 容量inf要哭出来了。。。。。要建双向边!!!!不过方向容量0View Code 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 const int maxn = 505; 9 const int maxm = 20005; 10 const int inf = 99999999; 11 int cnt,head1[ maxn ]; 1... 阅读全文
posted @ 2013-03-03 23:40 xxx0624 阅读(429) 评论(0) 推荐(0) 编辑
摘要: 水题~只需记录下改变的行,列即可。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 const int maxn = 1005; 5 const int maxm = 100005; 6 int mat[ maxn ][ maxn ]; 7 int row[ maxn ],col[ maxn ]; 8 9 int main(){10 int T;11 scanf("%d",&T);12 int ca=1;13 while( T-- ){1 阅读全文
posted @ 2013-03-03 19:50 xxx0624 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 题意:翻转某些牌 使得达到目标状态BFS+位运算因为整个图比较小,所以用位运算来记录状态。View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<queue> 5 using namespace std; 6 const int inf = 0x7fffffff; 7 const int maxn = 16; 8 const int maxm = 65535; 9 int vis[ maxm+5 ];10 int dis[ maxm+5 阅读全文
posted @ 2013-03-03 19:21 xxx0624 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 水题~暴力即可。View Code 1 #include<stdio.h> 2 #include<math.h> 3 int main(){ 4 double now; 5 double a[ 305 ]; 6 a[ 1 ]=0.5; 7 for( int i=2;i<305;i++ ){ 8 a[ i ]=a[ i-1 ]+1.0/(1.0*i+1.0); 9 }10 while( scanf("%lf",&now),now ){11 int ans=1;12 for( int i=1;i<30... 阅读全文
posted @ 2013-03-03 17:39 xxx0624 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 对于期望,首先,对于这个公式中p表示概率,x表示随机变量展开则为 ex= p1*x1+p2*x2+p3*x3.......对于本题 假设 ex[ i ]表示当前 i 走到 n 的期望值。所以若 i 处没有飞机,ex[ i ]=sigma(1/6*ex[i+k])+1 其中(k=1...6) (+1表示掷了一次骰子) 若 i 处有飞机,则直接等于 ex[ j ]结果则为 ex【0】View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace 阅读全文
posted @ 2013-03-01 18:35 xxx0624 阅读(871) 评论(0) 推荐(0) 编辑
摘要: 题意:给定一串数字,在这些数字钟插入一些‘+’或者'=' 使得两边相等思路:首先暴力出这个字符串中任意两个位置的表示的数的大小。。。。然后枚举等号的位置,两边进行dfs(dfs一开始实在是没思路。。借鉴http://blog.csdn.net/kk303/article/details/8008058)View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 const int maxn = 24; 6 c 阅读全文
posted @ 2013-03-01 17:11 xxx0624 阅读(773) 评论(0) 推荐(0) 编辑
摘要: 题意:引爆一个炸弹会同时引爆与它相距d的炸弹重点:由于x,y坐标的范围很大,所以必须离散化,显而易见。在这里可以利用sort+unique进行离散化并存储在myhash中。其次由于一个点可能多次放炸弹,但只有一次有效,所以用一个vis数组记录所以对于任意一个炸弹(x,y,d)。首先由x-d,x+d在myhash中确定y在set的范围first_pos,last_pos然后 再在set中按照y的范围寻找。。。View Code 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #incl. 阅读全文
posted @ 2013-02-28 22:32 xxx0624 阅读(525) 评论(0) 推荐(0) 编辑
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 42 下一页