#P3923. Finite Field Verification
Finite Field Verification
Finite Field Verification
In this problem, you are given a positive integer ( n ). You need to determine whether a finite field of ( n ) elements can be constructed using the elements ( 0, 1, \dots, n-1 ) with operations defined as addition and multiplication modulo ( n ). A structure ( (\mathbb{Z}_n, +, \times) ) forms a finite field if it satisfies the following axioms:
- There is an additive identity ( o ) such that for every element ( a ), ( o + a = a + o = a ).
- Every element ( a ) has an additive inverse ( a^{-1} ) such that ( a + a^{-1} = a^{-1} + a = o ).
- There is a multiplicative identity ( i ) (different from ( o )) such that ( i \times a = a \times i = a ) for every element ( a ).
- Every non-zero element ( a ) (i.e. every element except the additive identity) has a multiplicative inverse ( a^{-1} ) such that ( a \times a^{-1} = a^{-1} \times a = i ).
- Addition is commutative: ( x + y = y + x ) for any ( x, y ).
- Multiplication is commutative: ( x \times y = y \times x ) for any ( x, y ).
- Addition is associative: ( (x + y) + z = x + (y + z) ) for any ( x, y, z ).
- Multiplication is associative: ( (x \times y) \times z = x \times (y \times z) ) for any ( x, y, z ).
- Multiplication is distributive over addition: ( (x + y) \times z = x \times z + y \times z ) for any ( x, y, z ).
Note that in the output the additive identity ( o ) is represented as ( 0 ) and the multiplicative identity ( i ) as ( 1 ).
A key fact from field theory is that the finite field ( \mathbb{Z}_n ) (i.e. the integers modulo ( n )) forms a field if and only if ( n ) is a prime number. (Recall that finite fields of order ( n ) exist if and only if ( n = p^k ) for some prime ( p ) and integer ( k \geq 1 ); however, when ( k > 1 ), the elements cannot be represented simply as ( 0, 1, \dots, n-1 ) with standard modulo arithmetic.)
Your task is to check whether the given integer ( n ) is a prime number (with ( n > 1 )). If yes, output "YES"; otherwise, output "NO".
inputFormat
The input consists of a single integer ( n ) (( 1 \leq n \leq 10^9 )).
outputFormat
Output a single line containing either "YES" if a finite field can be constructed (i.e. if ( n ) is a prime number), or "NO" otherwise.
sample
2
YES