結果

問題 No.16 累乗の加算
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-17 13:05:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 416 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 2,059 ms
コンパイル使用メモリ 71,984 KB
実行使用メモリ 56,392 KB
最終ジャッジ日時 2023-09-08 11:36:43
合計ジャッジ時間 6,520 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,784 KB
testcase_01 AC 123 ms
55,864 KB
testcase_02 AC 416 ms
56,392 KB
testcase_03 AC 207 ms
55,680 KB
testcase_04 AC 218 ms
56,016 KB
testcase_05 AC 227 ms
56,332 KB
testcase_06 AC 327 ms
56,008 KB
testcase_07 AC 272 ms
56,044 KB
testcase_08 AC 333 ms
55,992 KB
testcase_09 AC 352 ms
55,952 KB
testcase_10 AC 305 ms
56,200 KB
testcase_11 AC 133 ms
56,076 KB
testcase_12 AC 307 ms
55,464 KB
testcase_13 AC 221 ms
56,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        long x= koko.nextLong();
        int n= koko.nextInt();
        long[] a = new long[n];
        long total=0;
        for(int i=0; i<n; i++){
            a[i]=koko.nextLong();
            a[i]=a[i]%1000002;
            long t=1;
            for(long j=0; j<a[i]; j++){
                t=(t*x)%1000003;
            }
            total = (total+t)%1000003;
        }
        System.out.println(total);
        
    }
}
0