結果

問題 No.1486 ロボット
ユーザー lloyzlloyz
提出日時 2022-01-06 22:44:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 701 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 50,048 KB
最終ジャッジ日時 2024-04-25 08:26:21
合計ジャッジ時間 3,836 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
10,752 KB
testcase_01 AC 34 ms
10,752 KB
testcase_02 AC 35 ms
10,880 KB
testcase_03 AC 32 ms
10,880 KB
testcase_04 AC 38 ms
10,880 KB
testcase_05 AC 32 ms
10,752 KB
testcase_06 AC 701 ms
50,048 KB
testcase_07 AC 595 ms
50,048 KB
testcase_08 AC 289 ms
22,400 KB
testcase_09 AC 28 ms
10,880 KB
testcase_10 AC 66 ms
13,568 KB
testcase_11 AC 66 ms
13,568 KB
testcase_12 AC 30 ms
10,880 KB
testcase_13 AC 26 ms
10,752 KB
testcase_14 AC 209 ms
21,760 KB
testcase_15 AC 62 ms
13,184 KB
testcase_16 AC 102 ms
16,384 KB
testcase_17 AC 96 ms
15,488 KB
testcase_18 AC 108 ms
16,384 KB
testcase_19 AC 46 ms
12,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

a, b, c, d, e = map(int, input().split())

lcm_n = (a + b) * (c + d) //gcd(a + b, c + d)
DP = [0 for _ in range(lcm_n + 1)]
for i in range(lcm_n):
    if 0 <= i % (a + b) < a and 0 <= i % (c + d) < c:
        DP[i + 1] = 1
for i in range(lcm_n):
    DP[i + 1] += DP[i]

q, r = divmod(e, lcm_n)
print(q * DP[-1] + DP[r])
0