#P11961. Primitive Root Check

    ID: 14071 Type: Default 1000ms 256MiB

Primitive Root Check

Primitive Root Check

Given a prime number p, an integer g is called a primitive root modulo p if it satisfies the following conditions:

  • 1 < g < p
  • \(g^{p-1} \equiv 1 \pmod{p}\)
  • For every integer \(1 \le i < p-1\), \(g^i \not\equiv 1 \pmod{p}\).

Given two integers p and a where p is prime, determine whether a is a primitive root modulo p.

inputFormat

The input consists of one line containing two integers p and a, where p is a prime number and a is the integer to be tested.

outputFormat

Output Yes if a is a primitive root modulo p, otherwise output No.

sample

5 2
Yes