結果

問題 No.16 累乗の加算
ユーザー shi-moshi-mo
提出日時 2016-10-19 19:33:12
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 441 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 142,960 KB
実行使用メモリ 393,964 KB
最終ジャッジ日時 2023-09-02 22:27:17
合計ジャッジ時間 7,442 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 619 ms
275,196 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 916 ms
393,964 KB
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

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;

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