#P10570. Meshed Gears

    ID: 12591 Type: Default 1000ms 256MiB

Meshed Gears

Meshed Gears

You are given two meshed gears, A and B. Gear A must rotate a times such that gear B rotates exactly b times. In order to satisfy precision requirements, each gear must have at least c teeth.

Formally, assume gear A has TA teeth and gear B has TB teeth with the conditions:

  • TA, TB \(\ge c\)
  • \(a \cdot T_A = b \cdot T_B\)

Find the minimum possible value of \(T_A + T_B\).

inputFormat

The input consists of a single line containing three integers a, b, and c.

outputFormat

Output a single integer: the minimum total number of teeth on gears A and B.

sample

2 3 4
10