摘要: View Code 1 /* 2 dp[ i ]:偷钱i而不被抓的最大概率(因为要使得被抓的概率最小) 3 开始想把dp[i]定义为概率为i的最大价值,因为把i放大了100,不过还是不够。 4 然后看题解才明白要转化,dp[i]:偷i这么多钱的最大不被捕的概率,也就是不被抓的最小概率 5 */ 6 #include<stdio.h> 7 #include<string.h> 8 #include<algorithm> 9 using namespace std;10 const int maxn = 10015;11 double dp[ maxn ];12 阅读全文
posted @ 2013-05-08 19:25 xxx0624 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 带权的并查集View Code 1 /* 2 带权值的并查集 3 ps:对于两个不在同一个集合里面的两个元素,把父节点接在一起即可 4 */ 5 #include<stdio.h> 6 #include<string.h> 7 #include<stdlib.h> 8 #include<algorithm> 9 #include<iostream>10 #include<queue>11 #include<map>12 #include<math.h>13 using namespace std;1 阅读全文
posted @ 2013-05-08 15:25 xxx0624 阅读(347) 评论(0) 推荐(0) 编辑