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

24059번 - Function 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB4791189326.124%

문제

You are given a function $f ,円 : ,円 \mathbb{N}_0 \to \mathbb{N}_0$ defined as below. ($\mathbb{N}_0$ denotes the set of non-negative integers.)

  • $f(0) = a_0$
  • $f(i) = a_i^{f(i - 1)}$ ($i \ge 1$)

Find the value of $f(n)$ modulo $m$.

입력

The first line contains a single integer $n$.

The second line contains $n + 1$ integers $a_0, ,円 a_1, ,円 \cdots, ,円 a_n$.

The third line contains a single integer $m$.

출력

Print the value of $f(n)$ modulo $m$.

제한

  • 0ドル \le n \le 2$
  • 1ドル \le a_i \le 2 \times 10^9$ (0ドル \le i \le n$)
  • 2ドル \le m < 2 \times 10^9$; $m$ is a prime number.
  • All values in input are integers.

예제 입력 1

2
2 3 2
11

예제 출력 1

6

$f(0) = 2,ドル $f(1) = 3^2 = 9,ドル $f(2) = 2^9 = 512$.

The value of 512ドル$ modulo 11ドル$ is 6ドル$.

노트

As a note, the exact value of 9ドル^{9^9}$ has a whopping 369ドル ,円 693 ,円 700$ digits.

출처

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

출처

대학교 대회

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

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