这个题目也比较有意思,让自己写代码实现幂运算,这里最大的问题是时间复杂度,负责的话编程实现非常容易。贴出代码,注意其中对奇偶数的判断。public class Solution { public double pow(double x, int n) { if(x==1){ ...
分类:
其他好文 时间:
2014-10-22 01:02:28
阅读次数:
117
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below ...
分类:
其他好文 时间:
2014-10-21 02:13:40
阅读次数:
211
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.就是判断haystack中是否有needle,如果包...
分类:
其他好文 时间:
2014-10-21 00:54:00
阅读次数:
151
Implement insert and delete in a tri-nary tree. A tri-nary tree is much like a binary tree but with three child nodes for each parent instead of two -...
分类:
其他好文 时间:
2014-10-19 02:40:16
阅读次数:
236
题意很好懂,就是求N^N的最左边的那个数是多少,N的范围那么大,很明显直接计算想都不用想,那应该怎么样呢?当然是用公式了啊:
10^(n*lg(n)-[n*lg(n)])=pow(10,n*log10(n)-(int)(n*lg(n)))
要问这个公式怎么来的,现在来推导一下:
设n^n=a0*10^m+a1*10^(m-1)+...
a0,a1...为相应位的系数,m为数字位个数,如4^4=256,a0=2,a1=5,a2=6,m=3;
很明显a0就是最左边的数,也就是我们想要的,那么我们就来求a0;
a...
分类:
其他好文 时间:
2014-10-18 14:07:26
阅读次数:
189
CSRF(Cross Site Request Forgery)是常見但不顯眼的攻擊方式,本篇不介紹如何使用CSRF攻擊 只有介紹如何透過Express去實作CSRF protection 要實作CSRF protection要開啟一些功能(session, csrf, cookieParser...
分类:
其他好文 时间:
2014-10-18 12:45:06
阅读次数:
175
前面几节看得真心累,现在先来点简单容易理解的内容。
一 math包
math包主要处理数学相关的运算。
常数
math.e # 自然常数e
math.pi # 圆周率pi
运算函数
math.ceil(x) # 对x向上取整,比如x=1.2,返回2
math.floor(x) # 对x向下取整,比如x=1.2,返回1
math.pow(...
分类:
编程语言 时间:
2014-10-18 08:37:49
阅读次数:
239
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.Solution: 1 public class S...
分类:
其他好文 时间:
2014-10-18 08:35:09
阅读次数:
162
1,先看看官方的定义吧:
ZooKeeper is a distributed, open-source coordination service for distributed applications. It exposes a simple set of primitives that distributed applications can build upon to implement...
分类:
其他好文 时间:
2014-10-17 21:58:54
阅读次数:
242
注意会超long long开i次根号方法,te=(ll)pow(n,1.0/i);Yukari's BirthdayTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm...
分类:
其他好文 时间:
2014-10-17 21:39:18
阅读次数:
120