#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
oracle使用LEFT JOIN关联产生的问题在查询结果中使用CASE WHEN
无法判断查询方式一: 1 SELECT 2 CASE WHEN (SELECT CAST(SUM(CASE 3 WHEN
(ALLOCABLE_PRIME_CURRENCY_VALUE IS NULL AND ST....
分类:
数据库 时间:
2014-05-18 20:08:35
阅读次数:
1129
hash做法:#include#includeconst int Max =
100010;int home[Max],away[Max],hash[Max];int main(){ int n,sum,total; int i,j;
while(scanf("%d",&n)!=E...
分类:
其他好文 时间:
2014-05-17 21:44:37
阅读次数:
504
原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1425
DP题。 f[i][j]表示当前数字为i,分解式中最大质数为j的方案数,那么,状态转移方程为: f[i][j] = sum(f[i-j][k]) 其中...
分类:
其他好文 时间:
2014-05-17 20:41:17
阅读次数:
296
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