No.1161 Many Powers
Problem Statement
You are given integers $A,B,C$, each at least $1$.
Find the remainder when $1^B+2^B+3^B+\cdots+A^B$ is divided by $C$.
Input
$A\ \ \ B\ \ \ C$
All input values are integers.
$1 \leq A,B \leq 10^{12}$
$1 \leq C \leq 10^5$
Output
Output the answer on $1$ line.
Print a newline at the end.
Sample
Sample 1
Input
2 4 5
Output
2
Since $1^4+2^4=17$, output $2$, the remainder when divided by $5$.
Sample 2
Input
6 5 83
Output
0
Since $1^5+2^5+3^5+4^5+5^5+6^5=12201$, it is divisible by $83$. Therefore, output $0$.
Source
Nada High School 75th Class Junior High Graduation Commemorative Contest: Many Powers
writer: Mitsubachi
tester: Mitarushi
Ported in accordance with HackerRank's terms of service. Some parts have been modified.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂