結果

問題 No.16 累乗の加算
ユーザー shi-moshi-mo
提出日時 2016-10-19 19:40:30
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 883 ms / 5,000 ms
コード長 472 bytes
コンパイル時間 4,437 ms
コンパイル使用メモリ 147,100 KB
実行使用メモリ 394,016 KB
最終ジャッジ日時 2023-09-02 22:27:40
合計ジャッジ時間 11,355 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 828 ms
393,668 KB
testcase_03 AC 303 ms
153,420 KB
testcase_04 AC 384 ms
192,776 KB
testcase_05 AC 448 ms
223,528 KB
testcase_06 AC 553 ms
275,416 KB
testcase_07 AC 606 ms
300,952 KB
testcase_08 AC 722 ms
352,964 KB
testcase_09 AC 883 ms
383,856 KB
testcase_10 AC 761 ms
377,576 KB
testcase_11 AC 795 ms
394,016 KB
testcase_12 AC 790 ms
391,836 KB
testcase_13 AC 785 ms
390,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.string;
import std.array;
import std.algorithm;
import std.conv;

void main() {
    uint x, n; readf("%s %s\n", &x, &n);
    uint[] a = readln.strip.split.map!(to!uint).array.sort().array;

    const uint M = 1000003;
    uint amax = a[n-1];
    uint[] m = new uint[amax + 1];
    m[0] = 1;
    if (0 < amax) { m[1] = x % M; }
    foreach (i; 2..(amax+1)) {
        m[i] = (m[i-1] * m[1]) % M;
    }
    writeln(a.map!(ai => m[ai]).sum % M);
}
0