#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
Question 1: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...
分类:
其他好文 时间:
2014-05-19 09:35:41
阅读次数:
321
题目:合并两个有序单链表思路:一开始想复杂了,以为必须在原链表上修改(绕来绕去还AC了,但是思路相当绕),其实没有,按照正常地合并两个数组同样的方法也对。代码:public
ListNode mergeTwoLists(ListNode l1, ListNode l2) { if(l1 ...
分类:
其他好文 时间:
2014-05-19 07:48:32
阅读次数:
314
【题目】
原文:
1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one...
分类:
其他好文 时间:
2014-05-16 01:50:08
阅读次数:
311
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
【题目】
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a contain...
分类:
其他好文 时间:
2014-05-16 01:32:47
阅读次数:
406
线段树维护的是区间有多少个空位置,每次查询第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
介绍ViewFlipper
ViewFlipper
Simple ViewAnimator that will animate between two or more views that have been added to it. Only one child is shown at a time. If requested, can automatically flip betwee...
分类:
其他好文 时间:
2014-05-15 18:37:44
阅读次数:
356