#includeint sum(int* a, int n){ return (0 == 
n)?0:(sum(a,n-1) + a[n-1]);}void sum1(int* a, int n,int& s){ if(0 == n) 
return; else {...
                            
                            
                                分类:
其他好文   时间:
2014-05-19 20:33:20   
                                阅读次数:
381
                             
                    
                        
                            
                            
                                题意:就是一个人走到一个城市就会记录与该城市相连的城市有多少,最后判断这些城市是否全部相连;样例输入87 7 
4 3 3 3 2 1105 4 3 3 2 2 2 1 1 
1样例输出NOYES解题思路:其实就是判断无向连通图,sum#include#include#include #includeu...
                            
                            
                                分类:
其他好文   时间:
2014-05-19 10:13:47   
                                阅读次数:
306
                             
                    
                        
                            
                            
                                题目链接:HDU 1394 Minimum Inversion 
Number【题意】给你一个1~N的数字组成的初始序列,然后每一次都将第一个数字移到最后,形成新的序列,然后求出这些序列的逆序数中的最小值。【思路】开始可以用任意一种方法(线段树 
or 暴力 or 树状数组)计算出初始数列的逆序数sum...
                            
                            
                                分类:
其他好文   时间:
2014-05-19 09:50:31   
                                阅读次数:
282
                             
                    
                        
                            
                            
                                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....
                            
                            
                                分类:
其他好文   时间:
2014-05-16 01:34:36   
                                阅读次数:
293
                             
                    
                        
                            
                            
                                线段树维护的是区间有多少个空位置,每次查询第X个空位置在哪,sum[rt]>=X就向左区间找,sum[rt]
#include 
#include 
#include 
using namespace std;
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 55555;
int...
                            
                            
                                分类:
其他好文   时间:
2014-05-15 20:19:48   
                                阅读次数:
256
                             
                    
                        
                            
                            
                                和上一题一样,寻找第K个位置,只不过需要处理一下下一个位置在哪,画图看看就知道了。
#include 
#include 
#include 
using namespace std;
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = 30000+5;
int sum[maxn<<...
                            
                            
                                分类:
其他好文   时间:
2014-05-15 20:07:28   
                                阅读次数:
262
                             
                    
                        
                            
                            
                                Given two binary strings, return their sum 
(also a binary string).For example, a = "11" b = "1" Return "100".string 
的操作,短string补位。两个“0”会输出一个“00”,要特殊处理...
                            
                            
                                分类:
其他好文   时间:
2014-05-15 17:47:57   
                                阅读次数:
283
                             
                    
                        
                            
                            
                                为了照到点Point(x0,y0),圆心可以在一个范围内移动,我们设该范围为(x,y)(Vec[i].x,Vec[i].y)表示第如果圆心在这个范围内,则第i个点就一定能照到,sum表示为了能照到前i个点,最靠近右边的圆的边界坐标。#define 
LOCAL#include#include#incl...
                            
                            
                                分类:
其他好文   时间:
2014-05-15 14:31:11   
                                阅读次数:
237
                             
                    
                        
                            
                            
                                简单点说其实Segment Tree就是二分法的灵活运用。
需要的基础知识:
1 二分法
2 二叉树
3 最好熟悉堆排序
操作就是二分法和堆排序巧妙地合并起来。
有了这些基础知识Segment Tree就没有任何难度了。
参考原文:
http://www.geeksforgeeks.org/segment-tree-set-1-sum-of-given-range/
...
                            
                            
                                分类:
其他好文   时间:
2014-05-15 13:33:33   
                                阅读次数:
250
                             
                    
                        
                            
                            
                                [ 问题: ]
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 the ta...
                            
                            
                                分类:
其他好文   时间:
2014-05-15 00:04:39   
                                阅读次数:
377