結果

問題 No.1486 ロボット
ユーザー kokatsukokatsu
提出日時 2022-05-09 20:02:44
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 3,014 ms
コンパイル使用メモリ 202,600 KB
実行使用メモリ 14,100 KB
最終ジャッジ日時 2023-09-04 17:05:21
合計ジャッジ時間 3,569 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 29 ms
14,100 KB
testcase_07 AC 30 ms
13,036 KB
testcase_08 AC 16 ms
8,284 KB
testcase_09 AC 2 ms
4,388 KB
testcase_10 AC 4 ms
4,384 KB
testcase_11 AC 4 ms
4,384 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 9 ms
6,112 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 6 ms
4,928 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 6 ms
6,148 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/dmd2/linux/bin64/../../src/phobos/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`

ソースコード

diff #

import std;

void main() {
    long A, B, C, D, E;
    readf("%d %d %d %d %d\n", A, B, C, D, E);

    long s = A + B, t = C + D;
    long l = s * t / gcd(s, t);

    auto R1 = new bool[](l), R2 = new bool[](l);
    foreach (i; 0 .. l) {
        R1[i] = (i % s < A);
        R2[i] = (i % t < C);
    }

    auto both = new long[](l);
    foreach (i; 0 .. l) {
        if (i > 0) both[i] += both[i-1];
        if (R1[i] && R2[i]) ++both[i];
    }

    auto d = E / l, r = E % l;

    long res = both.back * d;
    if (r > 0) res += both[r-1];

    res.writeln;
}
0