The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have...
分类:
其他好文 时间:
2014-05-10 09:11:21
阅读次数:
334
【题目】
原文:
1.3 Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An
extra copy of...
分类:
其他好文 时间:
2014-05-07 08:48:12
阅读次数:
372
题目大意:
给出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
Paint the Grid Reloaded
Time Limit: 2 Seconds
Memory Limit: 65536 KB
Leo has a grid with N rows and M columns. All cells are painted with either black or white initially.
Two cells A ...
分类:
其他好文 时间:
2014-05-07 07:28:35
阅读次数:
480
题意:经典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
The gray code is a binary numeral system where two successive values differ in only one bit.
Given a non-negative integer n representing the total number of bits in the code, print the sequence of gr...
分类:
其他好文 时间:
2014-05-07 06:10:17
阅读次数:
370
[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
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