Happy Great BGTime Limit: 2000msMemory Limit: 65536KB64-bit integer IO format:%lld Java class name:MainSubmitStatusPID: 28894The summer training of ZJ...
分类:
其他好文 时间:
2015-08-29 15:22:35
阅读次数:
123
题意:
给出一颗n个结点的树,点上有权值;
求点对(x,y)满足x!=y且x到y的路径上最大值与最小值的差
n
题解:
来填一填当年挖下的坑;
这个数据范围真是恶意。。直接说五组数据不好吗!
考虑这题怎么做,在这场考试那天的前一天,我学习了树分治算法;
然后他就出了,然后我就写了,然后我就写不出来了;
当年的我实在naive;
我翻出了当时交上去的代码,改了好久好久。。...
分类:
移动开发 时间:
2015-08-28 17:35:07
阅读次数:
295
【202-Happy Number(开心数字)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Write an algorithm to determine if a number is “happy”.
A happy number is a number defined by the...
分类:
移动开发 时间:
2015-08-26 08:19:14
阅读次数:
204
/**
*题目:请实现一个函数,把字符串中的每个空格替换成”%20”。例如输入“We are happy.”,则输出”We%20are%20happy.”
*时间:2015年8月25日10:34:31
*文件:ReplaceBlank.java
*作者:cutter_point
*/
package bishi.Offer50.y2015.m08.d25;
public class R...
分类:
其他好文 时间:
2015-08-25 16:50:44
阅读次数:
130
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer...
分类:
移动开发 时间:
2015-08-21 13:24:26
阅读次数:
131
Problem DescriptionConsider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to determine S modulo 29...
分类:
移动开发 时间:
2015-08-21 01:40:15
阅读次数:
198
#include<stdio.h>
#include<assert.h>
#include<stdlib.h>
voidreplace_space(char*str)
{
assert(str);
char*pstr=str;
intspace=0;
intlen=0;
intnewlen=0;
while(*str)
{
if(*str==‘‘)
space++;
len++;
str++;
}
newlen=len+space..
分类:
移动开发 时间:
2015-08-21 00:29:11
阅读次数:
316
题目:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive inte...
分类:
移动开发 时间:
2015-08-20 22:15:46
阅读次数:
250
题目描述
请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为”We Are Happy.“则经过替换之后的字符串为“We%20Are%20Happy.”
解析
直观的想法是,新建一个数组,逐个复制,遇到空格时,写入%20,但这需要占用额外空间。
如果我们顺序的遍历字符串,当遇到空格时,用%20替换空格,这将覆盖掉空格后面的字符
如果覆盖前,后移剩余字符串,那么移动的时...
分类:
编程语言 时间:
2015-08-20 16:49:40
阅读次数:
117
Description
Background
Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from t...
分类:
其他好文 时间:
2015-08-19 00:45:06
阅读次数:
135