题解 | #碰撞的蚂蚁#
碰撞的蚂蚁
http://www.nowcoder.com/practice/83073edaa76b4d179ee0366518a58dba
class Ants {
public:
double antsCollision(int n) {
//只有所有蚂蚁同向时才不会相撞
return 1 - pow(0.5, n-1);
}
};
碰撞的蚂蚁
http://www.nowcoder.com/practice/83073edaa76b4d179ee0366518a58dba
class Ants {
public:
double antsCollision(int n) {
//只有所有蚂蚁同向时才不会相撞
return 1 - pow(0.5, n-1);
}
};
相关推荐