- 博客(33)
- 资源 (2)
- 收藏
- 关注
原创 tc-SRM-626-DIV1-250
枚举alice投掷骰子得到的结果的每一种情况极其数量。枚举bob投掷骰子得到的结果的每一种情况极其数量。然后枚举alice投掷骰子得到的结果的数量和bob投掷骰子比alice低的数量。然后计算结果。#include #include #include #include #include #include #include #include #include usi
2014-06-29 16:38:12 1230
原创 Codeforces Round #249 (Div. 2)-D
这场的c实在不想做,sad。D:标记一下每一个点8个方向不经过黑点最多能到达多少个黑点。由题意可知,三角形都是等腰三角形,那么我们就枚举三角形的顶点。对于每一个定点,有8个方向可以放三角形。然后枚举8个方向,然后枚举腰的长度。然后判断是否可行。#include #include #include #include #include #include #inclu
2014-06-29 15:10:50 936
原创 hdu-4035-Maze-树上的概率dp
对于叶子节点和非叶子节点非别列公式。然后化简公式。和非树上的差不多。。#include#include#include#include#include#include#includeusing namespace std;#define eps 1e-9#define zero(x) ((fabs(x)<eps?0:x))#define maxn 11000#de
2014-06-27 15:48:53 946
原创 hdu-4089-Activation-概率dp
kuangbin题解写的很好,我就不赘余了。。一下解释来自kuangbin:题意:有n个人排队等着在官网上激活游戏。Tomato排在第m个。对于队列中的第一个人。有一下情况:1、激活失败,留在队列中等待下一次激活(概率为p1)2、失去连接,出队列,然后排在队列的最后(概率为p2)3、激活成功,离开队列(概率为p3)4、服务器瘫痪,服务器停止激活,所有人都无法激活了。
2014-06-25 16:05:32 1451
原创 hdu-4418-Time travel-高斯+概率dp
把N个点先转化为2*N-2个点。比如说把012345转化成0123454321。这样,就可以找出任意两两个点之间的关系。然后根据关系可以得出来一个一元多项式的矩阵。然后就用高斯消元求出矩阵即可。#include#include#include#include#include#includeusing namespace std;#define eps 1e-6#
2014-06-24 23:35:04 1720
原创 zoj-3329-One Person Game-有环的概率DP
感觉kuangbin写的题解不错,就直接抄袭过来啦。。。地址:http://www.cnblogs.com/kuangbin/archive/2012/10/03/2710648.html题意:有三个骰子,分别有k1,k2,k3个面。每次掷骰子,如果三个面分别为a,b,c则分数置0,否则加上三个骰子的分数之和。当分数大于n时结束。求游戏的期望步数。初始分数为0设dp[i
2014-06-24 15:31:52 978
原创 hdu-4336-Card Collector-概率DP
以后还是使用递推把,不能用记忆化了,记忆化太耗时间了。。。因为N很小,所以我们可以用状态压缩。用压缩起来的状态表示已经拥有的卡片。然后根据状态之间的关系进行求解。#include #include#include#includeusing namespace std;#define maxn 110000#define eps 1e-6#define zero(x) (f
2014-06-23 21:15:21 1093 5
原创 zoj-3640-Help Me Escape-概率DP
dp[x]:能力为x的时候,逃出的期望。则,可以根据x,来算出期望的公式。#include #include#include#includeusing namespace std;#define maxn 110000#define eps 1e-6#define zero(x) (fabs(x)<0?0:x)double dp[maxn];int c[maxn];in
2014-06-23 20:32:54 930
原创 hdu-4405-Aeroplane chess-概率DP
还是那么做。。。无非加了一条跳转。。。几乎都差不多。。#include #include#include#includeusing namespace std;#define maxn 110000#define eps 1e-6#define zero(x) (fabs(x)<0?0:x)double dp[maxn];int pre[maxn];int n;dou
2014-06-23 19:39:47 758
原创 hdu-3853-LOOPS-概率dp
用记忆化写概率DP写的越来越纯真了。。感觉记忆化很好写。。。#include #include#include#includeusing namespace std;#define maxn 1100#define eps 1e-6#define zero(x) (fabs(x)<0?0:x)double mp[maxn][maxn][4];double dp[maxn]
2014-06-23 19:31:22 865
原创 poj-2096-Collecting Bugs-概率DP
期望dp。dp[x][y]:已经遇到x个bug,y个sub,还需要的期望步数。则:设:p1=x/n;p2=(n-x)/n;p3=y/s;p4=(s-y)/s;dp[x][y]=p1*p3*(dp[x][y]+1) +p2*p4*(dp[x+1][y+1]+1) +p2*p3*(dp[x+1][y]+1) +p1*p4*(dp[x][y+1]
2014-06-23 15:48:34 813
原创 codeforces-148D-Bag of mice-概率DP
dp[x][y]:现在有x个白老鼠,y个黑老鼠,公主赢的概率。那么:如果公主直接拿到白老鼠,概率为x/(x+y),公主赢。如果公主拿到黑老鼠,概率为y/(x+y),那么公主如果想赢,龙必须拿到黑老鼠,概率为(y-1)/(x+y-1);那么逃跑的老鼠为黑老鼠的概率为(y-2)/(x+y-2),为白老鼠的概率为(x)/(x+y-2);那么dp[x][y]=x/(x+y)+y/(x+
2014-06-22 13:58:54 1199
原创 zoj-3790-Consecutive Blocks
使用l,r指针游动。然后使用记录游动过程中的最大值。我离散化了一下。#include#include#include#include#include#includeusing namespace std;#define maxn 110000mapmp;struct list{ int x; int get; int lose; in
2014-06-21 17:41:45 1225
原创 poj-3791-An Easy Game-记忆化搜索
dp[i][j]:还有i个不相同的位置,还能走j步,一共有多少种走法。很明显dp[i][j]=sigm(dp[i-k][j-1]*c[i][k]*c[n-i][m-k]);用记忆化搜索记忆一下即可。#include#include#include#include#include#include#includeusing namespace std;#define m
2014-06-21 17:40:11 1079
原创 zoj-3792-Romantic Value-最小割+数值转化
如果不需要求边的个数的话,就是一个裸的最小割问题。求边的个数就用边的权值记录一下。#include #include #include #include #includeusing namespace std;#define INF 99999999#define LL long longconst LL maxn =55;const LL maxm =4400;con
2014-06-21 17:37:43 1070
原创 zoj-3795-Grouping-tarjan缩点求最长路
用tarjan进行缩点。然后用dfs求最长路。水体。。。#include#include#include#include#include#include#includeusing namespace std;#define maxn 110000vectorold[maxn];vectorvec[maxn];int dnf[maxn],low[maxn],instac
2014-06-21 17:36:14 1352
原创 poj-3744-Scout YYF I-矩阵乘法
f[i]=f[i-1]*p+f[i-2]*(1-p);正好可以用矩阵加速。。。。#include#include#include#include#includeusing namespace std;struct matr{ double mat[3][3]; friend matr operator *(const matr a,const matr b)
2014-06-20 22:47:42 1166
原创 Codeforces Round #251 (Div. 2)-C,D
C题:思路很简单。由题意可知,奇数的集合有k-p个,偶数的几何有p个。那么我们先选择k-p-1个奇数,每一个奇数是一个集合。然后我们再选择p个偶数,每一个偶数是一个集合,如果偶数的个数不足,那么就用两个奇数去补。然后我们再把剩下的所有的数放在一个集合里。By rowanhao, contest: Codeforces Round #251 (Div. 2), problem
2014-06-20 20:30:55 1172
原创 Codeforces Round #253 (Div. 1)-A,B
A题:由题意可知,最多翻10次就可以(其实8次就够了),那么我们就用状态压缩表示状态。对于某种状态,如果某一位为0,那么代表这一位不翻,否则代表这一位翻。对于某一种翻的状态:如果牌中有G3,那么就把G和3进行连边。其他的连边类似,不要重边。对于任意一条边的两个端点,分三种情况讨论:1,两个端点都翻了,那么很明显,这张牌被表示出来了。2,两个端点中只有一个端点被翻,那么这
2014-06-20 19:58:05 1156 2
原创 Codeforces Round #252 (Div. 2)-C,D
C题就是一个简单的模拟,首先给每个人两个。然后把剩下的都给一个人就好了。给的时候蛇形给。#include#include#include#include#include#includeusing namespace std;#define LL __int64#define maxn 330000int main(){ int n,m,k; while(
2014-06-19 13:07:12 1020
原创 湘潭-1203-A simple problem
地址:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1203做法:假如n等于10^12。那么n%1...n%10^6暴力解。复杂度o(10^6)对于任意的n%x=y;得: x*t+y=n;(t>=1&&t对于任意的t,第一个x*t+y=n的x1为n/(t+1)+1;最后一个x*t+y=n的x
2014-06-17 00:00:18 1500
原创 poj-3580-SuperMemo-splay
迷人的伸展树、、、都是伸展树很裸的操作,没什么技术含量。标记下放的时候注意一下就好。。。#include#include#include#include#includeusing namespace std;#define LL long long#define maxn 220000#define mem(a,b) memset(a,b,sizeof(a))#def
2014-06-15 20:34:10 1180
原创 hdu-2475-Box-splay
伸展树是那么的迷人,总是让你在希望的时候WA,在绝望的时候AC。。。。。做这个题没有之前,首先要了解树形结构转线性的做法。推荐连接:http://blog.csdn.net/lyhypacm/article/details/6734748本题做法:对于本题的每一个最外层的盒子建立一颗伸展树。对于move x y操作:(1)把x为根的子树切下来。(2)然后把切下来的子树放
2014-06-12 22:40:55 1873
原创 hdu-4453-Looploop-splay
真的被这道题目恶心到了。。。281行代码。。。比一个模拟题还费事。。。为了方便起见,在数列的前面和后面都加一个0点。add x :把第k2+2个点旋转至root1.然后sum[root10]+=x;reverse:把第k1+2个点旋转至root1.然后rev[root10]^=1; insert x:得到第2个点,然后在第2个点之后插入x。 delete :把第1个点旋
2014-06-12 15:17:29 1313
原创 poj-3481-Double Queue-splay树的水题
很水的splay树。会简单的操作即可。。。#include#include#include#include#includeusing namespace std;#define maxn 1100000#define mem(a,b) memset(a,b,sizeof(a))#define root10 ch[ch[root][1]][0]#define root1 c
2014-06-11 21:09:26 2187
原创 hdu-4288-Coder-线段树
感觉今天的状态有点不好。。。老是在小地方犯错。。。简单的记录一下就好。#include#include#include#include#include#include#include#include#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;#define maxn
2014-06-11 19:56:00 798
原创 poj-3225-Help with Intervals
超级恶心的一道题目。。。查错查了一个小时。。。。1,要用C++,用G++会wa。2,注意检查边界。3,注意标记的下放方式。#include#include#include#include#include#include#include#include#pragma comment(linker, "/STACK:1024000000,1024000000")u
2014-06-11 17:19:48 824
原创 sgu-319-Kalevich Strikes Back-线段树
线段树记录当前区间是哪一个长方形在覆盖。然后根据每一条线更新线段树。如果是左边的边,那么把区间更新成当前长方形。否则,把区间更新成当前长方形的前驱。#include#include#include#include#include#include#include#include#pragma comment(linker, "/STACK:1024000000,102
2014-06-11 15:19:02 1051
原创 hdu-4419-Colourful Rectangle-线段树求面积并
这道题目很有意思,写的麻烦了,估计得写很长时间。幸好,我一开始就想出来了比较简单的方法。。。利用位运算,把颜色RGB分别用1,2,4,表示。那么就可以根据当前区间的状态来求当前区间每一种状态的长度了。#include#include#include#include#include#include#include#include#pragma comment(link
2014-06-10 20:27:19 918
原创 hdu-3642--Get The Treasury-线段树求面积并
求空间中叠加3次及3次以上的体积。因为|z|然后对于每一层进行线段树求面积并。#include#include#include#include#include#include#include#include#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;#defin
2014-06-10 17:28:53 1009
原创 poj-1151-Atlantis-线段树求面积并
很裸的线段树求面积并。坐标需要离散化一下。#include#include#include#include#include#include#include#include#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;#define maxn 11000#define
2014-06-10 15:55:28 829
原创 excle查找操作-vlookup的使用心得
百度了一下vlookup的语法规则:该函数的语法规则如下:VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)参数简单说明输入数据类型lookup_value要查找的值数值、引用或文本字符串
2014-06-10 13:14:10 2048
餐饮管理系统设计说明书
2014-12-08
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人