标签:style blog io ar java for sp 2014 on
小球下落:function f(depth,count){
var states = new Array();
var r;
for(var i = 0;i < count;i++){
for(var root = 1;root <Math.pow(2,depth-1);){
if(states[root] && states[root].open){
states[root].open = false;
root = root * 2 + 1;
}
else{
if(!states[root]){states[root]={open:true};}
else if(states[root].open == false){states[root].open = true;}
root = root * 2;
}
r=root;
}
}
return r;
}
console.log(f(4,2));
console.log(f(3,4));
console.log(f(10,1));
console.log(f(2,2));
console.log(f(8,128));
console.log(f(16,12345));标签:style blog io ar java for sp 2014 on
原文地址:http://blog.csdn.net/lan_liang/article/details/40159605