y*********0 发帖数: 406 | 1 下面这个是recursive版本的
public class PowX {
public double pow(double x, int n) {
if(n==0 )
return 1.0 ;
if(x==1.0 )
return x;
if(x==-1.0 )
return n%2 ==0 ? 1.0:-1.0;
int sign = n>0 ? 1 :-1 ;
n=sign> 0 ? n:-n;
double pow = getPow(x,n);
return sign > 0 ? pow : 1.0/pow;
}
private double getPow(double x, int n){
if(n==1 )
return x;
int odd = n%2 ;
... 阅读全帖 |
|
w****x 发帖数: 2483 | 2 double pow(double x, int n) {
if (n < 0)
return 1/pow(x, -n);
if (n == 0)
return 1;
double mul = n%2 == 1 ? x : 1;
double db = pow(x, n/2);
return db*db*mul;
}
why?????? |
|
l**h 发帖数: 893 | 3 比如下面这个log(n)的, 很容易实现,为什么喜欢考这个题?
public double pow(double x, int n) {
if (n == 0) return 1;
if (x == 0) return 0;
boolean positive = true;
if (n < 0) {
positive = false;
n = -n;
}
double tmp = pow(x, n/2);
double ret;
if (n%2 == 0) {
ret = tmp*tmp;
}
else {
ret = x*tmp*tmp;
}
return positive ? ret : 1.0/ret;
} |
|
a***e 发帖数: 413 | 4 为啥下面这个出错,用pow(5,k)就可以呢?多谢!
class Solution {
public:
int trailingZeroes(int n) {
int c=0;
int f=5;
while(n/f>0)
{
c+=n/f;
f*=5;
}
return c;
}
};
Input:1808548329Output:452137080Expected:452137076
Correct one
class Solution {
public:
int trailingZeroes(int n) {
int c=0;
int f=5;
int k=1;
while(n/f>0)
{
c+=n/f;
k++;
f=pow(5,k);
... 阅读全帖 |
|
o*****t 发帖数: 227 | 5 这次让我很后悔上次打折的时候没有拿下Pontoon. 在bottomless pow里面我的130-92-
112 无rocker的volkl bridge没法完全放松, 每次太随意,就容易nose dip. 很多时
候我只能用类似Buttering的动作滑。比较累。看网上高手用更窄的无rocker ski也能
控制得很随意。我郁闷了。
其实我的stance比较neutral,没有过分前倾的问题(因为我的telemark binding),
但是
脚下技术不够细,晚上总结了一下,可能pow里面ankle flex需要更主动,而不是通
过重心变化来引导?
P.S. 我用的厂家推荐mounting point,没有象很多freestyle的人那样前移。 |
|
s*****2 发帖数: 472 | 6 imagine of finding fresh pow at Sun Valley or Lake Louis! I am very happy
with the pow we could find at Verbier as a result. |
|
g**1 发帖数: 10330 | 7 Was Taliban PoW a deserter before he was captured and held for five years?
Soldier 'sent emails that he was planning to leave his post after becoming
disillusioned with the war'
原来是个逃兵。 水很深。
But there is controversy, too. Rolling Stone magazine quoted emails Bergdahl
is said to have sent to his parents that suggest he was disillusioned with
America's mission in Afghanistan, had lost faith in the U.S. Army's mission
there and was considering desertion.
http://www.dailymail.co.uk/news/article-2645... 阅读全帖 |
|
N*****8 发帖数: 253 | 8 看到有不少版友提到被问到实现pow函数的问题。问题本身不难,但是如何检测并处理
溢出呢? |
|
g*********e 发帖数: 14401 | 9 我弄错了。。。开跟好可能是用二分法或者牛顿法找解吧,利用pow函数凑 |
|
|
c********t 发帖数: 5706 | 11 最后一种解法貌似也是lgn的。按n的binary走的,本质与n/2应该一样
pow(double, double)应该怎么做? |
|
w***o 发帖数: 109 | 12
好像不是Constant time。任然是O(lgn)。而且还可以简化:
public class Solution {
public double pow(double x, int n) {
boolean isNeg = n < 0;
if(n < 0)
n = -n;
double ret = 1.0;
while(n>0) {
if((n&1) >0)
ret *= x;
x *= x;
n >>= 1;
}
return isNeg? 1.0/ret : ret;
}
} |
|
|
c******e 发帖数: 558 | 14 Because pow returns double. Changing your f variable from int to double
gives same result
★ 发自iPhone App: ChineseWeb 1.0.2 |
|
|
j****7 发帖数: 786 | 16 just broke 2nd resistance at 4.01...
boom boom pow |
|
j****7 发帖数: 786 | 17 boom boom pow tomorrow! |
|
|
j****7 发帖数: 786 | 19 this is AMD in 2005 and 2009, boom boom pow! |
|
m******u 发帖数: 12400 | 20 是到自家车库里(或趴车场了)开车,还是到tsla dealer那里去开车?
发信人: imperalism (aslkdjlskjdlk), 信区: Stock
标 题: Re: AMD BOOM BOOM POW !
发信站: BBS 未名空间站 (Tue Apr 1 18:07:18 2014, 美东)
我和你说不清楚,不同的case,一会儿我去开特斯拉去了。 |
|
i********m 发帖数: 332 | 21 Dealer 来接我去拿车 哈哈哈哈!!!
boom boom pow! |
|
|
|
j****7 发帖数: 786 | 24 富贵在天,祝你明天boom boom pow! |
|
|
j****7 发帖数: 786 | 26 sold nmbl few days ago to get AMD
so happy!
boom boom pow! |
|
j****7 发帖数: 786 | 27 求大牛赏个pick!
boom boom pow! |
|
j****7 发帖数: 786 | 28 谢大牛,明天就买,然后晒帐户!
boom boom pow! |
|
i********m 发帖数: 332 | 29 What will BBP next Monday?
Could be DATA, FENG, QIHU, YY, SFUN?
No. I think AMD will BOOM BOOM POW next week. YMYD. |
|
l*******4 发帖数: 406 | 30 也是前几天看了才知道这个,确实很带感!
蝌蚪10点前问大牛,今天走势怎么看?
龙霸了,你可以说Boom Boom 爆!
砸盘了,你可以说Boom Boom 梆!
轻轻的一句Boom Boom Pow,立于不败之地,深藏功与名…… |
|
|
|
|
|
|
|
h**********9 发帖数: 3252 | 37 以前的衰股现在都成了香饽饽了,AT&T和PG&E这段时间都boom,boom,pow!! |
|
|
|
x***k 发帖数: 3311 | 40 Nice video about the "某人". The pow was really nice. |
|
x***k 发帖数: 3311 | 41 Way too rocky/icy, where is the "pow"?! |
|
|
s*****2 发帖数: 472 | 43 帅哥向导skiing this part of the pow |
|
s*****2 发帖数: 472 | 44 hehe, a little bit, but loved it :))) As for skis, all my skis are rock skis
and they only last 2/3 seasons even at pow Squaw. Looking at this part 帅哥
said "it is good we have skis huh?" I answered "wish we were born skiing
instead of walking".
looking forward to seeing your pics of Zermatt and others as we will be
there. |
|
s*****2 发帖数: 472 | 45 hehe, a little bit, but loved it :))) As for skis, all my skis are rock skis
and they only last 2/3 seasons even at pow Squaw. Looking at this part 帅哥
said "it is good we have skis huh?" I answered "wish we were born skiing
instead of walking".
looking forward to seeing your pics of Zermatt and others as we will be
there. |
|
|
a*******r 发帖数: 3452 | 47 楼主府上哪里?这个powder的pow和湖北(武汉附近)土语里面的那个一声的pao很像兄
弟伙的,意思很近。 |
|
r*******i 发帖数: 1640 | 48 不知道你们那是啥规矩,我们这儿的pow wow是不能随便拍随便贴的 |
|
|
m*******y 发帖数: 422 | 50 你看wiki英文里南屠词条,也能发现一些有趣的东西。5万到30万是原始资料,4万到30
万是学者调查,而30万则是中国政府和中国学者的结论。在不否认屠杀性质的前提下,
具体遇难人数还是一个学术问题。类似于64事件和大跃进中的死难人数。
Result
50,000-300,000 dead (primary sources)[1][2]
40,000-300,000 dead (scholarly consensus)[3]
300,000 dead (Chinese government, scholarly consensus in China)[4][5][6]
Individual or group
Estimate of total massacred
Civilians massacred
Soldiers massacred
Notes on the killing of Chinese soldiers
Area and duration under consideration
References
Government of China
300,000
only the... 阅读全帖 |
|