結果

問題 No.1486 ロボット
ユーザー TomoyarnTomoyarn
提出日時 2021-12-27 17:05:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 1,439 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 85,776 KB
最終ジャッジ日時 2023-10-26 02:48:54
合計ジャッジ時間 2,822 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,776 KB
testcase_01 AC 39 ms
53,776 KB
testcase_02 AC 38 ms
53,776 KB
testcase_03 AC 38 ms
53,776 KB
testcase_04 WA -
testcase_05 AC 38 ms
53,776 KB
testcase_06 AC 60 ms
77,968 KB
testcase_07 WA -
testcase_08 AC 53 ms
70,168 KB
testcase_09 AC 38 ms
53,776 KB
testcase_10 AC 47 ms
61,540 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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