Under construction

Still being built. Things may change

Big Bang

Time limit1sMemory limit512 MB

Summary
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 (0,0,0)(0, 0, 0) at time T=0T = 0. More precisely it was a fixed velocity lattice Big Bang. Just before the Big Bang every particle sat at (0,0,0)(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.

  1. A particle moves along a straight line that starts at (0,0,0)(0, 0, 0).
  2. Every particle starts at time T=0T = 0. Two particles can share a direction, but then their speeds differ. No two particles are at the same place at the same time.
  3. The speed of each particle is constant.
  4. The number of particles is unlimited.
  5. The xx, yy and zz components of every velocity are positive.
  6. Every particle is a point with no size.
  7. 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 11 and NN, and take readings up to NN 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)(1, 1, 1) one microsecond after the Big Bang and the particle detected at (2,2,2)(2, 2, 2) 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 NN and is at most 8000080000.

Output

For each integer in the input, print on its own line the largest number of distinct particles that can be detected.

Examples2

  1. Example 1

    Input
    1
    1
    10000
    10000
    80000
    
    Expected output
    1
    1
    9239427676877311
    9239427676877311
    37844569649859454367
    
  2. Example 2

    Input
    1
    2
    3
    4
    5
    
    Expected output
    1
    15
    79
    239
    607