Just like find a number in a binary search tree. The only trick is keeping record of the current node's left and right node to get to its child node.Code:/************************************************************************* * Copyright (C) 2008
Simple problem. Just record the absolute values of the differences will do the job.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng
At the first look, the hartals can be counted with the principle of inclusion and exclusion. However, this may cause the calculations to expand to O(2^numberof(parties)). In another way, simply simulation will also do the job.Code:/******************
問題描述:不說了,。。。解法:dijkstra+state represented by binary codenotes: if a state must meet "**1**1**" <=> (state | "00100100")==state and if a state must meet "**0**0**" <=> (state & “11011011” ==state) so if you
The simplest problem ever since...Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng at gmail dot com
MONITORING theperformance of hosts in your cluster is somewhat a boring task. I'veseen various programs written to access system usage informations withhandmade methods, such as filtering output of commands, or readingfields from files in the '/proc'
We can easily observe that if the drawn number is in range [2, 9], Stan will win, and if it is in range [10, 18], Ollie will win. Suppose that one of Span's win range is [m, n], it can be extend to the next win range of [2*m+1, 2*9*n)]. Thus, the
The coefficient of x1n1x2n2...xknk is (n, n1)(n-n1, n2)...(n-n1-n2-...-nk-1, nk) = n!/n1!n2!...nk!.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng
Simple simulation will do the job.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng at gmail dot com
This problem can be solved by a BFS on a graph that modeling the doublet relationships. If the pair of a and b forms a doublet, then there is a edge between a and b in the graph.You can divide the dictionary into portions by word size, then handle
I use the naive string search method that scans for the eight directions at each point in the matrix. Due to the relatively small input size, this method work well enough to get the top 20% ranking.Code:/**********************************************
Really simple problem. However, two points need to be considered:1. ... find the largest string x such that there is a permutation of x that is a (not necessarily continuous) subsequence of a ...2. if there are spaces in the input, ignore them in
Not a difficult problem. Just catenate the lines together and compare the correct and submitted answer will do it well. Unfortunately, the problem statement is misleading: I get WA consistently with a "linesize" of 102, however, it becomes AC when I