結果

問題 No.16 累乗の加算
ユーザー Flere0114
提出日時 2016-02-27 11:41:43
言語 Java
(openjdk 23)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 569 bytes
コンパイル時間 3,655 ms
コンパイル使用メモリ 75,228 KB
実行使用メモリ 41,600 KB
最終ジャッジ日時 2024-06-26 05:10:25
合計ジャッジ時間 6,683 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Scanner;

public class No16 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger x, a, ans, mod;
        int N;

        x = new BigInteger(sc.next());
        N = sc.nextInt();
        mod = new BigInteger("1000003");
        ans = new BigInteger("0");

        for (int i = 0; i < N; i++) {
            a = new BigInteger(sc.next());
            ans = ans.add(x.modPow(a, mod));
            ans = ans.mod(mod);
        }

        System.out.println(ans);
    }
}
0