結果

問題 No.1486 ロボット
ユーザー TomoyarnTomoyarn
提出日時 2021-12-27 17:18:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 85,728 KB
最終ジャッジ日時 2023-10-26 03:02:38
合計ジャッジ時間 2,289 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,744 KB
testcase_01 AC 39 ms
53,744 KB
testcase_02 AC 40 ms
53,744 KB
testcase_03 AC 40 ms
53,744 KB
testcase_04 AC 39 ms
53,744 KB
testcase_05 AC 39 ms
53,744 KB
testcase_06 AC 60 ms
77,920 KB
testcase_07 AC 66 ms
85,728 KB
testcase_08 AC 53 ms
70,120 KB
testcase_09 AC 40 ms
53,744 KB
testcase_10 AC 50 ms
61,492 KB
testcase_11 AC 49 ms
61,492 KB
testcase_12 AC 45 ms
59,860 KB
testcase_13 AC 40 ms
53,744 KB
testcase_14 AC 58 ms
69,912 KB
testcase_15 AC 50 ms
63,908 KB
testcase_16 AC 54 ms
66,368 KB
testcase_17 AC 57 ms
65,552 KB
testcase_18 AC 54 ms
65,520 KB
testcase_19 AC 49 ms
63,392 KB
権限があれば一括ダウンロードができます

ソースコード

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

print(ans)



0