問題一覧 > 通常問題

No.487 2017 Calculation

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 342
作問者 : butsurizuki / テスター : tatuyan_edson
お気に入りにしたユーザー ProblemId : 1407 / 自分の提出
問題文最終更新日: 2026-06-26 20:17:33
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 157 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。