题目大意:
给出m个询问,问【l,r】之间的和 ,求出有多少次询问不和之前的矛盾的。
思路分析:
用并查集记录当前节点到根节点的和。
#include
#include
#include
#include
#define maxn 222222
using namespace std;
int set[maxn];
int sum[maxn];
in...
分类:
其他好文 时间:
2014-05-07 07:35:05
阅读次数:
386
题意:经典Nim游戏博弈,给你n堆牌,每堆a[i]张,每次能从一堆中取出任一张(不能为0),最后不能取者为输
问先手有几种取法保证他最后能获胜。
思路:让Nim_sum=0(a[1]^a[2]…………^a[n]=0)时则输,利用这个定理,对于第i堆a[i],除了第i堆,其它的
Nim_sum=k,如果a[i]>k,则先手从第i堆可以取a[i]-k张牌,让a[i]=k,最后a[i]^k...
分类:
编程语言 时间:
2014-05-07 06:13:32
阅读次数:
428
[Question]
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to t...
分类:
其他好文 时间:
2014-05-07 05:37:44
阅读次数:
278
当使用移动设备进行触控操作时,最常用的就是轻击、按住屏幕或者手势操作,jQuery Mobile可以通过绑定的触控事件来响应使用者的特定触控行为。一、轻击与按住直接上代码(一切皆在代码中,细细品吧!)
练习
<meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1....
分类:
移动开发 时间:
2014-05-07 04:45:59
阅读次数:
426
为了方便说明和更加直观的展示jquerymobile的页面初始化过程以及各个事件的触发过程,我绘制了一幅流程图:图中用红色框圈起来的是界面中的事件,测试代码如下:
练习
<meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=0;...
分类:
移动开发 时间:
2014-05-07 04:40:07
阅读次数:
450
Maximum Weight Difference
Chef has gone shopping with his 5-year old son. They have bought N items so far. The items are numbered from 1 to N, and the item i weighs Wi grams.
Chef's son insist...
分类:
其他好文 时间:
2014-05-06 22:59:49
阅读次数:
451
1、
??
Candy
There are N children standing in a line. Each child is assigned a rating value.
You are giving candies to these children subjected to the following requirements:
Each child must h...
分类:
其他好文 时间:
2014-05-06 22:41:02
阅读次数:
427
NYOJ 640 Geometric Sum...
分类:
其他好文 时间:
2014-05-06 15:20:32
阅读次数:
229
【Question】
Given an array S of n integers, are there elements a, b, c in S such
that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
Elements in ...
分类:
其他好文 时间:
2014-05-06 14:57:29
阅读次数:
318