結果

問題 No.1486 ロボット
ユーザー TomoyarnTomoyarn
提出日時 2021-12-27 17:05:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 86,436 KB
最終ジャッジ日時 2024-09-25 10:49:18
合計ジャッジ時間 1,982 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
    ans = cnt * (N // LCD)
else:
    ans = dp[:N].count(2)

print(ans)



0