There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner.
What is the probability that they don't collide?
Answer
Let's mark the corners of the triangle as A,B,C. There are total 8 ways in which ants can move.
1. A->B, B->C, C->A
2. A->B, B->C, C->B
3. A->B, B->A, C->A
4. A->B, B->A, C->B
5. A->C, C->B, B->A
6. A->C, C->B, B->C
7. A->C, C->A, B->Ajavascript:void(0)
8. A->C, C->A, B->C
Out of which, there are only two cases under which the ants won't collide :
A->B, B->C, C->A
A->C, C->B, B->A
Consider the following example:
class B { ... };
class D : public B { ... };
void f()
{
B* pb = new D; // unclear but ok
B* pb2 = new B;
D* pd = dynamic_cast...
No comments:
Post a Comment