题目地址:HDU 4961
看来这题的测试数据是随机的。不然出了极限数据还真过不了。。。这题我的方法是建一个哈希结构体,记录两个变量,分别是num位置,然后是f,f==0表示这个数没出现过,f==1表示这个数出现过。然后分别从前面和后面扫一遍。每次扫的时候,对每一个出现的数都进行标记。然后对当前的数枚举该数的倍数,全部枚举完,取位置num最大的。然后找完之后,对哈希结构体进行更新。如果前面曾经出...
分类:
其他好文 时间:
2014-08-19 19:03:45
阅读次数:
209
Boring Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 80 Accepted Submission(s): 39
Problem Description
Number theory is in...
分类:
其他好文 时间:
2014-08-19 19:02:05
阅读次数:
319
Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[?...
分类:
其他好文 时间:
2014-08-19 18:12:55
阅读次数:
279
sum[i][j] 表示从第1到第i头cow属性j的出现次数
所以题目要求等价为:
求满足
sum[i][0]-sum[j][0]=sum[i][1]-sum[j][1]=.....=sum[i][k-1]-sum[j][k-1] (j
中最大的i-j
将上式变换可得到
sum[i][1]-sum[i][0] = sum[j][1]-sum[j][0]
sum[i][2]-sum...
分类:
其他好文 时间:
2014-08-19 16:38:24
阅读次数:
247
看题目请戳我
#include
#include
#include
#include
using namespace std;
#define maxx 10050
int num[maxx];//记录孩子的个数
int dp[maxx];//记录把这个节点删除之后剩下的最大的连通度
int sum;
vector root[maxx];
bool vis[maxx];
int df...
分类:
其他好文 时间:
2014-08-19 16:34:05
阅读次数:
223
group by 的意思为分组汇总。使用了group by 后,要求Select出的结果字段都是可汇总的,否则就会出错。比如,有:{学号,姓名,性别,年龄,成绩}字段 这样写:SELECT 学号,姓名,性别,年龄,sum(成绩)FROM 学生表GROUP BY 学号就是错的,因为 “姓名、性别、年龄...
分类:
其他好文 时间:
2014-08-19 12:27:54
阅读次数:
184
SUM是对符合条件的记录的数值列求和 COUNT 是对查询中符合条件的结果(或记录)的个数 例如: 表fruit id ? ? name ? ?price 1 ? ? apple ? ? 3.00 2 ? ? pear ? ? ? 4.00 select count(price) from ...
分类:
数据库 时间:
2014-08-19 08:13:33
阅读次数:
258
题目:
链接
解答:
自底向上求解。left_max right_max分别返回了左右子树的最大路径和,如果左右子树最大路径和小于0,那么返回零, 用这个最大路径和和根节点的值相加,来更新最大值,同时, 更新返回该树的最大路径值。
代码:
class Solution {
public:
int max = INT_MIN;
int maxPathSum(TreeNode *...
分类:
其他好文 时间:
2014-08-18 23:39:53
阅读次数:
397
LCM (Least Common Multiple) of a set of integers is defined as the minimum number, which is a multiple of all integers of that set. It is interesting to note that any positive integer can be expressed...
分类:
其他好文 时间:
2014-08-18 23:38:13
阅读次数:
275
解题报告
题目传送门
#include
#include
#include
#include
#define inf 99999999
using namespace std;
int v,w[35],d[4],dw1,sum,dp[31*1000*100];
int main()
{
double Q,dw;
int n,i,j,m,t;
char c;
...
分类:
其他好文 时间:
2014-08-18 23:35:43
阅读次数:
270