2014-03-20 01:59

题目:有n只蚂蚁在正n边形的n个顶点,同时以同速率开始沿着边走。每只蚂蚁走的方向是随机的,那么这些蚂蚁至少有两只发生碰撞的概率是多少。

解法:只有所有蚂蚁都往一个方向走才不会碰撞,所以不碰的概率就是2/2^n,碰的概率就用1减去喽。

代码:

1 // 7.2 n ants are standing on the vertices of an n-edged equilateral polygon, they start walking at the same time, same speed.
2 // Every ant chooses randomly a direction to go. What is the probability of a collision.
3 // p = 2 / 2^n = 2^-(n - 1)
4 int main()
5 {
6     return 0;
7 }

 

 posted on 2014-03-20 02:03  zhuli19901106  阅读(235)  评论(0编辑  收藏  举报