結果

問題 No.16 累乗の加算
ユーザー te-shte-sh
提出日時 2017-01-11 19:25:50
言語 D
(dmd 2.106.1)
結果
MLE  
実行時間 -
コード長 403 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 89,100 KB
実行使用メモリ 784,920 KB
最終ジャッジ日時 2023-09-03 00:31:09
合計ジャッジ時間 12,353 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 MLE -
testcase_03 AC 351 ms
301,836 KB
testcase_04 AC 475 ms
382,560 KB
testcase_05 AC 569 ms
443,928 KB
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

const md = 1_000_003L;

void main()
{
  auto rd = readln.split, x = rd[0].to!long, n = rd[1].to!size_t;
  auto ai = readln.split.to!(long[]);

  auto maxA = ai.reduce!max;
  auto xi = new long[](maxA + 1);
  xi[0] = 1;
  foreach (i; maxA.iota)
    xi[i + 1] = (xi[i] * x) % md;

  auto r = ai.map!(a => xi[a]).sum % md;
  writeln(r);
}
0