結果

問題 No.16 累乗の加算
ユーザー yuppe19 😺
提出日時 2015-04-22 18:42:23
言語 Java
(openjdk 23)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 716 bytes
コンパイル時間 2,490 ms
コンパイル使用メモリ 89,168 KB
実行使用メモリ 41,936 KB
最終ジャッジ日時 2024-06-26 04:52:50
合計ジャッジ時間 5,352 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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