No.487 2017 Calculation
タグ : / 解いたユーザー数 342
作問者 :
butsurizuki
/ テスター :
tatuyan_edson
Problem Statement
To celebrate the fact that 2017 is a prime number, p came up with the following expression.
$2017+(2017*2017)^{2017}$ (hereafter this value is denoted by $X$)
However, p learned that carrying out this calculation would produce an enormously huge number, and gave up on finding the exact value of $X$.
So, as a last wish, p has asked you, who are skilled at numerical computation, to find the remainder when $X$ is divided by a natural number $M$.
Given $M$, write a program that outputs the remainder when $X$ is divided by $M$.
Input
$M$
$M$ is given on a single line.
・Constraints
$1 \le M \le 2017$
Output
Output the remainder when $X$ is divided by $M$ on a single line.
A newline is required at the end of the output.
Sample
Sample 1
Input
523
Output
127
Sample 2
Input
2016
Output
2
Sample 3
Input
2017
Output
0
$X$ is a multiple of 2017.
Sample 4
Input
1
Output
0
Whatever number $X$ is, its remainder when divided by 1 is 0.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。