結果

問題 No.16 累乗の加算
ユーザー takeya_okinotakeya_okino
提出日時 2017-10-27 22:14:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 5,000 ms
コード長 484 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 71,592 KB
実行使用メモリ 60,392 KB
最終ジャッジ日時 2023-09-08 12:11:19
合計ジャッジ時間 5,111 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
60,204 KB
testcase_01 AC 139 ms
59,732 KB
testcase_02 AC 151 ms
60,060 KB
testcase_03 AC 144 ms
60,096 KB
testcase_04 AC 145 ms
60,136 KB
testcase_05 AC 147 ms
60,280 KB
testcase_06 AC 149 ms
60,092 KB
testcase_07 AC 146 ms
60,392 KB
testcase_08 AC 151 ms
60,232 KB
testcase_09 AC 149 ms
59,876 KB
testcase_10 AC 150 ms
59,608 KB
testcase_11 AC 140 ms
60,176 KB
testcase_12 AC 151 ms
59,824 KB
testcase_13 AC 150 ms
60,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int n = sc.nextInt();
    int[] r = new int[1000002];
    r[0] = 1;
    for(int i = 1; i < 1000002; i++) {
      r[i] = (r[i - 1] * x) % 1000003;
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      a = a % 1000002;
      ans = (ans + r[a]) % 1000003;
    }
    System.out.println(ans);
  }
}
0