結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー neko_the_shadowneko_the_shadow
提出日時 2017-03-20 23:19:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 72,468 KB
実行使用メモリ 56,240 KB
最終ジャッジ日時 2023-09-18 13:24:47
合計ジャッジ時間 5,238 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,536 KB
testcase_01 AC 124 ms
55,768 KB
testcase_02 AC 125 ms
55,592 KB
testcase_03 AC 125 ms
55,464 KB
testcase_04 AC 127 ms
55,796 KB
testcase_05 AC 124 ms
55,776 KB
testcase_06 AC 125 ms
55,524 KB
testcase_07 AC 123 ms
56,240 KB
testcase_08 AC 127 ms
55,896 KB
testcase_09 AC 125 ms
55,912 KB
testcase_10 AC 125 ms
56,056 KB
testcase_11 AC 124 ms
55,596 KB
testcase_12 AC 124 ms
55,888 KB
testcase_13 AC 125 ms
55,728 KB
testcase_14 AC 124 ms
55,884 KB
testcase_15 AC 127 ms
55,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main {
    public static long power(long x, long y, long z) {
        if (y == 0) return 1;
        return y % 2 == 0 ? power((x * x) % z, y / 2, z) : (power(x, y - 1, z) * x) % z;
    }
    
    
    
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        long m = Long.parseLong(stdin.nextLine());
        
        long answer = (2017 + power(2017 * 2017, 2017, m)) % m;
        System.out.println(answer);
    }
}
0