結果

問題 No.1486 ロボット
ユーザー hiragnhiragn
提出日時 2022-11-19 17:46:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,844 KB
実行使用メモリ 25,480 KB
最終ジャッジ日時 2023-10-20 23:05:31
合計ジャッジ時間 2,143 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,124 KB
testcase_01 AC 30 ms
10,124 KB
testcase_02 AC 32 ms
10,124 KB
testcase_03 AC 31 ms
10,124 KB
testcase_04 AC 29 ms
10,124 KB
testcase_05 AC 29 ms
10,124 KB
testcase_06 AC 197 ms
25,480 KB
testcase_07 AC 201 ms
25,480 KB
testcase_08 AC 108 ms
17,832 KB
testcase_09 AC 30 ms
10,124 KB
testcase_10 AC 43 ms
11,104 KB
testcase_11 AC 43 ms
11,104 KB
testcase_12 AC 29 ms
10,188 KB
testcase_13 AC 30 ms
10,124 KB
testcase_14 AC 89 ms
14,468 KB
testcase_15 AC 39 ms
10,840 KB
testcase_16 AC 49 ms
12,424 KB
testcase_17 AC 54 ms
11,632 KB
testcase_18 AC 50 ms
12,160 KB
testcase_19 AC 34 ms
10,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math


def main():
    a, b, c, d, e = map(int, input().split())

    cycle = (a + b) * (c + d) // math.gcd(a + b, c + d)
    dp = [0] * (cycle + 1)
    for i in range(cycle):
        if 0 <= i % (a + b) < a and 0 <= i % (c + d) < c:
            dp[i + 1] = 1

    q, r = divmod(e, cycle)
    ans = q * sum(dp[:]) + sum(dp[:r + 1])
    print(ans)


if __name__ == "__main__":
    main()
0