結果

問題 No.1486 ロボット
コンテスト
ユーザー Tomoyarn
提出日時 2021-12-27 17:18:18
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 579 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 126 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 84,992 KB
最終ジャッジ日時 2026-04-12 15:31:53
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math
M1, S1, M2, S2, N = map(int, input().split())

T1 = M1 + S1
T2 = M2 + S2

def my_lcm(x, y):
    return (x * y) // math.gcd(x, y)

LCD = my_lcm(T1, T2)

dp = [0] * (LCD * 2)

i = 0
while i <= LCD:
    for j in range(M1):
        dp[i] += 1
        i += 1
    for j in range(S1):
        i += 1

i = 0
while i <= LCD:
    for j in range(M2):
        dp[i] += 1
        i += 1
    for j in range(S2):
        i += 1


if LCD < N:
    cnt = dp[:LCD].count(2)
    mod = N % LCD
    ans = cnt * (N // LCD) + dp[:mod].count(2)
else:
    ans = dp[:N].count(2)

print(ans)



0