twOBoOgEr
Time limit1sMemory limit512 MB
Count every collision (A-B or A-wall) when B of mass n kg hits resting A of mass 1 kg elastically between a wall and B, for n up to 10^6.
- Level
Hard8 of 10
- Topics
- Math, Simulation, Binary search, Number theory
- Solved
- No attempts yet
Problem
Write a function P6.
- There are two objects A and B on a line, with a wall at the left. A is closer to the wall than B. Initially A and B are at rest, with masses 1 kg and kg. B suddenly moves toward A at a speed of 1 m/s and collides. The collision is elastic.
- input parameter: a positive integer ()
- return value: the number of collisions between A and B or between A and the wall
- Hint: When two objects with masses and collide with initial velocities (not speeds) and , the final velocities and satisfy . In an elastic collision, kinetic energy is conserved.