Big Bang
Time limit1sMemory limit512 MB
Count the maximum number of distinct particles detectable at lattice points in a 1..N cube, where a particle is a ray from the origin with positive integer velocity components.
- Level
Medium6 of 10
- Topics
- Number theory, Combinatorics
- Solved
- No attempts yet
Problem
A Big Bang happened at the coordinate at time . More precisely it was a fixed velocity lattice Big Bang. Just before the Big Bang every particle sat at with zero volume and infinite density. After the Big Bang the particles spread through three dimensional Cartesian space, and their motion obeys these rules.
- A particle moves along a straight line that starts at .
- Every particle starts at time . Two particles can share a direction, but then their speeds differ. No two particles are at the same place at the same time.
- The speed of each particle is constant.
- The number of particles is unlimited.
- The , and components of every velocity are positive.
- Every particle is a point with no size.
- The particles themselves are invisible. A particle is detected when it reaches a lattice point, a point whose three coordinates are all integers, at an integer time after the Big Bang. Sensors sit only at lattice points and fire once every microsecond. Time is measured in microseconds.
Put a sensor at every lattice point whose three coordinates are all between and , and take readings up to microseconds after the Big Bang. Find the largest number of distinct particles that can be detected. For example, the particle detected at one microsecond after the Big Bang and the particle detected at two microseconds after it are the same particle, because the direction and the speed agree.
Input
Five positive integers, one per line. Each integer is a value of and is at most .
Output
For each integer in the input, print on its own line the largest number of distinct particles that can be detected.