反向思考:如果把蚂蚁不相撞的概率剔除掉,剩下的就是相撞的。不撞的概率为顺时针和逆时针同向走,所以是0.5n*2,然后1-0.5n*2就可以了。 import math class Ants: def antsCollision(self, n): # write code here ...