結果

問題 No.1486 ロボット
ユーザー hiragn
提出日時 2022-11-19 17:46:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 26,480 KB
最終ジャッジ日時 2024-09-20 21:51:35
合計ジャッジ時間 2,323 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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