#C5080. Frog Jump Reachability

    ID: 48690 Type: Default 1000ms 256MiB

Frog Jump Reachability

Frog Jump Reachability

A frog starts at the coordinate 0 and can make jumps in two ways: either it jumps X meters to the right (forward) or Y meters to the left (backward). Your task is to determine whether the frog can reach exactly coordinate Z using any sequence of these jumps.

The mathematical condition for reachability is based on the greatest common divisor (GCD) of X and Y. In particular, the frog can reach Z if and only if:

\( Z \equiv 0 \pmod{\gcd(X,Y)} \)

Use this condition to decide if the destination is reachable. If it is, output "Yes"; otherwise, output "No".

inputFormat

The input consists of a single line containing three space-separated integers: X, Y, and Z, where:

  • X is the forward jump distance.
  • Y is the backward jump distance.
  • Z is the target coordinate.

All values are positive integers.

outputFormat

Output a single line containing either "Yes" if the frog can reach Z or "No" if it cannot.

## sample
3 2 1
Yes

</p>