結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー Mcpu3Mcpu3
提出日時 2018-09-01 16:57:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 373 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 73,840 KB
実行使用メモリ 57,732 KB
最終ジャッジ日時 2023-10-19 11:15:46
合計ジャッジ時間 5,521 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,408 KB
testcase_01 AC 136 ms
57,400 KB
testcase_02 AC 135 ms
57,216 KB
testcase_03 AC 135 ms
57,216 KB
testcase_04 AC 133 ms
57,732 KB
testcase_05 AC 134 ms
57,540 KB
testcase_06 AC 133 ms
57,304 KB
testcase_07 AC 133 ms
57,388 KB
testcase_08 AC 130 ms
57,380 KB
testcase_09 AC 130 ms
57,176 KB
testcase_10 AC 130 ms
57,508 KB
testcase_11 AC 134 ms
57,160 KB
testcase_12 AC 133 ms
57,468 KB
testcase_13 AC 135 ms
57,416 KB
testcase_14 AC 137 ms
57,164 KB
testcase_15 AC 141 ms
57,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
	public static long p(long x,long n,long m) {
		long r;
		if(1>n) return 1;
		r=p(x*x%m,n/2,m);
		if(n%2>0) r=r*x%m;
		return r;
	}
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long m=sc.nextLong();
		sc.close();
		System.out.print((2017+p(2017,2017,m)*p(2017,2017,m)%m)%m);
	}
}
0