1990题意:每头牛有两个属性v,x,计算sigma(max(v[i],v[j])*abs(x[i]-x[j]))1=x[j] +sigma(v[j]*(x[j]-x[i])) x[i]=x[j]其中dist.sum(maxn)-dist.sum(x[i]) 就是坐标在[x[i],maxn]...
分类:
其他好文 时间:
2014-07-07 14:26:47
阅读次数:
292
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100". 1 class Solution 2 { 3 public: 4 ...
分类:
其他好文 时间:
2014-07-03 11:23:54
阅读次数:
164
计算double类型的数时有时候会多出0.000000001,会有不确定个数的0,在计算时将其转为BigDecimal就不会出错。 BigDecimal sum = new BigDecimal(0.0); BigDecimal tmp = new BigDecimal(0.0); ...
分类:
编程语言 时间:
2014-07-01 19:16:36
阅读次数:
343
聚合函数:SQL中提供的聚合函数可以用来统计、求和、求最值等等。分类:–COUNT:统计行数量–SUM:获取单个列的合计值–AVG:计算某个列的平均值–MAX:计算列的最大值–MIN:计算列的最小值首先,创建数据表如下:执行列、行计数(count):标准格式SELECT COUNT() FROM 其...
分类:
数据库 时间:
2014-07-01 18:05:59
阅读次数:
234
https://oj.leetcode.com/problems/path-sum//** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNod...
分类:
编程语言 时间:
2014-07-01 13:09:20
阅读次数:
198
题目连接:uva 766 - Sum of powers
题目大意:将Sk(n)=∑i=1nik化简成Sk(n)=ak+1nk+1+aknk+?+a0M
解题思路:
已知幂k,并且有(n+1)k=C(kk)nk+C(k?1k)nk?1+?+C(0k)n0结论。
所以令 (n+1)k+1?nk+1=C(kk+1)nk+C(k?1k+1)nk?1+?+C(0k+1)n0
nk...
分类:
其他好文 时间:
2014-07-01 09:05:15
阅读次数:
261
题目:
链接:
题意:
思路:
代码:
#include
#include
#include
using namespace std;
const int N = 30030;
int root[N];
int sum[N],rank[N];//sum[i]表示i下面的积木个数
int q;
int findset(int x)
{
if(x == r...
分类:
其他好文 时间:
2014-07-01 08:12:55
阅读次数:
178
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [?2,1,?3,4,?1,2,1...
分类:
其他好文 时间:
2014-07-01 00:23:01
阅读次数:
248
这里笔者只写出关键代码:int add(int n,intm){ if(m==0) returnn; ① int sum=n^m; ② int carry=(n&m)<<1; ③ return add(sum,carry); ④} 在分析每步代码之前先看两个例子...
分类:
其他好文 时间:
2014-06-30 23:50:59
阅读次数:
428
题意:给你n个点m条边,问删除前i条边后有多少个连通分块。
思路:从后往前操作,从后往前添加i条边等于添加完m条边后删掉前m-i条边,可知刚开始没有边,所以sum[m]=n;
#include
#include
#include
#include
#include
#include
#define M 100010
#define LL...
分类:
其他好文 时间:
2014-06-30 20:26:50
阅读次数:
198