結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー tentententen
提出日時 2020-09-28 21:49:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 5,306 ms
コンパイル使用メモリ 71,324 KB
実行使用メモリ 57,560 KB
最終ジャッジ日時 2023-09-15 13:47:28
合計ジャッジ時間 6,775 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,664 KB
testcase_01 AC 126 ms
55,816 KB
testcase_02 AC 125 ms
55,660 KB
testcase_03 AC 123 ms
55,348 KB
testcase_04 AC 124 ms
55,916 KB
testcase_05 AC 124 ms
55,704 KB
testcase_06 AC 123 ms
55,668 KB
testcase_07 AC 126 ms
55,660 KB
testcase_08 AC 126 ms
55,688 KB
testcase_09 AC 123 ms
55,716 KB
testcase_10 AC 123 ms
56,032 KB
testcase_11 AC 124 ms
55,696 KB
testcase_12 AC 124 ms
56,012 KB
testcase_13 AC 124 ms
56,224 KB
testcase_14 AC 126 ms
55,904 KB
testcase_15 AC 124 ms
57,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int ans = 2017 % m + pow(pow(2017 % m, 2, m), 2017, m);
		ans %= m;
		System.out.println(ans);
	}
	
	static int pow(int x, int p, int m) {
	    if (p == 0) {
	        return 1;
	    } else if (p % 2 == 0) {
	        return pow(x * x % m, p / 2, m);
	    } else {
	        return pow(x, p - 1, m) * x % m;
	    }
	}
}
0