题解:异或操作是每一位独立的,所以我们可以考虑每一位分开做。假设当前正在处理第k位那令f[i]表示从i到n 为1的概率。因为不是有向无环图(绿豆蛙的归宿),所以我们要用到高斯消元。若有边i->j 权值为w,若w的k位为0,则f[i]+=1/du[i] * f[j],否则f[i]+=(1-f[j])/...
分类:
其他好文 时间:
2015-01-19 19:00:37
阅读次数:
143
Question:GivenanarrayAofintegers,findthemaximumofj-isubjectedtotheconstraintofA[i]<A[j].publicintmaxDistance(int[]A)
{
//Assumptions...
intlocal=Integer.MIN_VALUE;
intglobal=Integer.MIN_VALUE;
for(inti=1;i<A.length;i++)
{
if(A[i]>A[i-1])
{
local+..
分类:
其他好文 时间:
2015-01-19 11:04:11
阅读次数:
230
for(i=1;ia[i]) swap(a[i],a[j]); if(!a[i]) break; for(j=60;j>=0;j--) if(a[i]>>j&1) { for(k=1;k>j&1)) a[k]^=a[i]; break; }}对着这个代码思(...
分类:
其他好文 时间:
2015-01-18 17:00:14
阅读次数:
194
题解:n个元素的子集的最大异或和我居然理解了一星期 T_T lyd讲解坑死人。。。http://sujinyue.is-programmer.com/posts/42663.html这里解决了我的所有疑问。所谓线性基就是原数组所能xor出的一切数这个线性基都能xor出来,不多不少。为什么可以呢?我们...
分类:
其他好文 时间:
2015-01-18 13:01:27
阅读次数:
146
uva 111 History Grading
Many problems in Computer Science involve maximizing some measure according to constraints.
Consider a history exam in which students are asked to put several histori...
分类:
其他好文 时间:
2015-01-13 23:22:43
阅读次数:
513
题意:给一颗树,每次可以删掉一条与节点1(root)的连通的边,两人轮流操作,谁不能操作谁输。
题解:
只能套公式:
Colon原理:SG(x)=XOR{SG(y)+1|y是x的子结点}。
好了。水了。
代码:
#include
#include
#include
#include
#define N 101000
using namespace std;...
分类:
其他好文 时间:
2015-01-13 09:03:39
阅读次数:
153
A:就根据题意计算比较一下即可
B:从每个起点往后走一遍走到底,输出即可,字符串直接map映射掉
C:类似拓扑排序,从临接个数为1的入队,那么临接Xor和,其实就是他的上一个结点,因为他只临接了一个结点,这样利用拓扑排序,当一个结点的度数为1的时候入队即可,注意要判断一下度数0的情况,直接continue
D:利用树状数组去求这种大的全排列数,其实一个全排列 ,可以看成a1 * (n - 1...
分类:
其他好文 时间:
2015-01-13 00:08:12
阅读次数:
211
https://oj.leetcode.com/problems/single-number/http://blog.csdn.net/linhuanmars/article/details/22648829publicclassSolution{
publicintsingleNumber(int[]A)
{
//SolutionA
//returnsingleNum_Xor(A);
//SolutionB
returnsingleNum_BitCompare(A);
//SolutionC
//ret..
分类:
其他好文 时间:
2015-01-08 18:16:14
阅读次数:
141
1.java 运算符 主要是逻辑运算符和按位运算符;移位运算符-name tecmint.txt 逻辑运算符:And(&&) ; OR(||);Not(!) 按位运算符:And(&); OR(|); XOR(^);Not(~) 移位运算符:>> ; >> 按位运算符:...
分类:
编程语言 时间:
2015-01-07 14:38:29
阅读次数:
189
Given an array of integers, every element appears twice except for one. Find that single one.Analysis:Use XOR operation.Solution: 1 public class Solut...
分类:
其他好文 时间:
2014-12-23 06:41:18
阅读次数:
201