leetcode:HappyNumber,House Robber 1.Happy Number 这个题中收获2点: 1.拿到题以后考虑特殊情况,代码中考虑1和4,或者说<6的情况,动手算下。(可能要在代码一步步测试中发现,目前还不知道怎么知道这些特殊情况) 2.数字的每一位时,n%10,n/10。 ...
分类:
移动开发 时间:
2016-05-15 16:41:51
阅读次数:
292
D - Fliptile
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status
Description
Farmer John knows that an intellectually satisfied cow is a happy...
分类:
其他好文 时间:
2016-05-12 21:49:18
阅读次数:
229
题意描述:题意描述:实现一个函数把字符串中的每个空格替换成“20%”。例如:
输入:“we are happy”
输出:“we%20are%20happy”
解题思路:(C++实现方法)如果从前往后遍历,遇到空格再将字符向后移动,则假设有O(n)个空格的时间效率就是O(n^2)。因此优化的解法就是一次移到位,先遍历一次字符串,可同时得到字符串的长度和字符串中空格的数量,然后对于1个空格用...
分类:
编程语言 时间:
2016-05-12 21:15:11
阅读次数:
216
题目链接:点这里!!!!
题意:
给你两个整数m(1
题解:
直接二分+容斥。
代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define PI 2*...
分类:
移动开发 时间:
2016-05-12 20:35:21
阅读次数:
148
问题:在"we are happy"这个字符串中,将所有的空格替换成字符串%20.
分析:如果我们不定义一个新的字符数组,就在原字符数组中进行替换,要将一个字节的空格替换成三个字节的字符数组%20,这会产生数组的越界访问,如果允许我们开辟一个新的空间来存放替换后的字符串,则问题将会变得非常简单。
设置两个指针分别指向新旧字符串首元素,遍历原字符串,如果碰到空格就在新字符串上填入“%20”,否则...
分类:
其他好文 时间:
2016-05-11 01:32:26
阅读次数:
202
Heavy Transportation
Time Limit: 3000MS
Memory Limit: 30000K
Description
Background
Hugo Heavy is happy. After the breakdown of the Cargolifter project he ...
分类:
其他好文 时间:
2016-05-07 10:28:02
阅读次数:
301
delightful world 时间限制(C/C++):20000MS/30000MS 运行内存限制:65536KByte总提交:33 测试通过:10 描述 Siny was once a very happy boy. But one day, something awful happened. ...
分类:
其他好文 时间:
2016-04-26 17:22:41
阅读次数:
151
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 intege ...
分类:
移动开发 时间:
2016-04-25 06:39:05
阅读次数:
214