Wave Attack
Time limit2sMemory limit512 MB
Count how many reflected shockwave paths from the launcher reach the Count within t seconds, where simultaneous arrivals from different directions each count.
- Level
Medium6 of 10
- Topics
- Geometry, Math, Number theory, Implementation
- Solved
- No attempts yet
Problem
The valiant Ikta has finally cornered the notorious Count Bigbridge! The Count is now trapped in a rectangular room meters wide and meters deep, waiting for his end.
Choose one corner of the room, take the width direction as the -axis and the depth direction as the -axis, each oriented so that the interior of the room lies in the positive direction. The Count is at the point . At the point there is a shockwave launcher, Ikta's ultimate weapon, which fires a shockwave of meters per second in all directions. The shockwave remains active for seconds and reflects off the walls of the room.
Ikta, standing outside the room, wants to know how much the Count suffers, so write a program that finds how many times the shockwave hits the Count. When the shockwave hits the enemy from directions at the same time, count it as hits, and a shockwave that hits the enemy exactly seconds later is also valid. The shockwave is not extinguished by obstacles such as the launcher itself or the Count, and shockwaves do not interfere with each other.
Input
The input is given in the following format.
- Each is a positive integer as described in the problem statement.
Output
Print the number of times the shockwave hits Count Bigbridge on one line.