Official

C - 錬金術の対決 / Alchemy Showdown Editorial by harurun4635 Editorial for printing


最終的な値は、操作順に依らず \(\displaystyle \prod_{1}^{N} A_i \bmod P\) となります。


実装例

n, p = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
for x in a:
    ans = ans * x % p
print(ans)

posted:
last update: