結果

問題 No.16 累乗の加算
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-04-22 18:42:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 152 ms / 5,000 ms
コード長 716 bytes
コンパイル時間 2,502 ms
コンパイル使用メモリ 83,704 KB
実行使用メモリ 56,484 KB
最終ジャッジ日時 2023-09-08 11:36:34
合計ジャッジ時間 5,432 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,584 KB
testcase_01 AC 129 ms
55,476 KB
testcase_02 AC 150 ms
55,868 KB
testcase_03 AC 140 ms
56,264 KB
testcase_04 AC 139 ms
55,468 KB
testcase_05 AC 140 ms
55,756 KB
testcase_06 AC 149 ms
55,440 KB
testcase_07 AC 146 ms
55,660 KB
testcase_08 AC 149 ms
56,076 KB
testcase_09 AC 152 ms
56,016 KB
testcase_10 AC 149 ms
56,484 KB
testcase_11 AC 129 ms
56,128 KB
testcase_12 AC 146 ms
55,892 KB
testcase_13 AC 132 ms
55,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
import java.util.stream.*;

import static java.util.stream.Collectors.*;

public class Main {
    private static final BigInteger MOD = BigInteger.valueOf(1_000_003);
    private void solve() {
        Scanner sc = new Scanner(System.in);
        BigInteger x = BigInteger.valueOf(sc.nextInt());
        sc.nextLine();
        int res = Stream.of(sc.nextLine().split(" "))
                        .map(e -> x.modPow(new BigInteger(e), MOD))
                        .reduce(BigInteger.ZERO, (p, q) -> p.add(q).mod(MOD))
                        .intValue();
        System.out.println(res);
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}
0