Logo
(追記) (追記ここまで)

16808번 - Identity Function 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB91433447.222%

문제

You are given an integer $N,ドル which is greater than 1ドル$.

Consider the following functions:

  • $f(a) = a^N \bmod N$
  • $F_1(a) = f(a)$
  • $F_{k+1}(a) = F_k(f(a))~~(k = 1,2,3,\ldots)$

Note that we use $\mathrm{mod}$ to represent the integer modulo operation. For a non-negative integer $x$ and a positive integer $y,ドル $x \bmod y$ is the remainder of $x$ divided by $y$.

Output the minimum positive integer $k$ such that $F_k(a) = a$ for all positive integers $a$ less than $N$. If no such $k$ exists, output $-1$.

입력

The input consists of a single line that contains an integer $N$ (2ドル \le N \le 10^9$), whose meaning is described in the problem statement.

출력

Output the minimum positive integer $k$ such that $F_k(a) = a$ for all positive integers $a$ less than $N,ドル or $-1$ if no such $k$ exists.

제한

예제 입력 1

3

예제 출력 1

1

예제 입력 2

4

예제 출력 2

-1

예제 입력 3

15

예제 출력 3

2

힌트

출처

Contest > ICPC Japanese Alumni Group > JAG Summer Camp > JAG Summer Camp 2015 Day 4 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /