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.
Medium6Number theoryCombinatoricsNo attempts yetTime limit1sMemory limit512 MBA Big Bang happened at the coordinate (0,0,0) at time T=0. More precisely it was a fixed velocity lattice Big Bang. Just before the Big Bang every particle sat at (0,0,0) with zero volume and infinite density. After the Big Bang the particles spread through three dimensional Cartesian space, and their motion obeys these rules.
Put a sensor at every lattice point whose three coordinates are all between 1 and N, and take readings up to N microseconds after the Big Bang. Find the largest number of distinct particles that can be detected. For example, the particle detected at (1,1,1) one microsecond after the Big Bang and the particle detected at (2,2,2) two microseconds after it are the same particle, because the direction and the speed agree.
Five positive integers, one per line. Each integer is a value of N and is at most 80000.
For each integer in the input, print on its own line the largest number of distinct particles that can be detected.