結果

問題 No.1486 ロボット
ユーザー paruf4paruf4
提出日時 2021-04-23 22:14:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 519 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 31,728 KB
最終ジャッジ日時 2023-09-17 12:25:47
合計ジャッジ時間 3,255 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,940 KB
testcase_01 AC 17 ms
7,920 KB
testcase_02 AC 17 ms
7,904 KB
testcase_03 AC 16 ms
7,948 KB
testcase_04 AC 16 ms
7,936 KB
testcase_05 AC 17 ms
7,932 KB
testcase_06 AC 519 ms
31,728 KB
testcase_07 AC 510 ms
31,612 KB
testcase_08 AC 237 ms
19,904 KB
testcase_09 AC 17 ms
7,872 KB
testcase_10 AC 50 ms
9,836 KB
testcase_11 AC 52 ms
9,812 KB
testcase_12 AC 19 ms
8,320 KB
testcase_13 AC 17 ms
8,080 KB
testcase_14 AC 171 ms
14,732 KB
testcase_15 AC 50 ms
9,468 KB
testcase_16 AC 93 ms
11,644 KB
testcase_17 AC 87 ms
10,952 KB
testcase_18 AC 83 ms
11,316 KB
testcase_19 AC 36 ms
9,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

a, b, c, d, e = map(int, input().split())
x = a+b
y = c+d
cycle = x*y//gcd(x, y)

memo1 = [0]*cycle

pos = 0
for i in range(cycle//x):
    for j in range(a):
        memo1[pos] = 1
        pos += 1
    for j in range(b):
        pos += 1
memo2 = [0]*cycle
pos = 0
for i in range(cycle//y):
    for j in range(c):
        memo2[pos] = 1
        pos += 1
    for j in range(d):
        pos += 1

memo = [0]*cycle

for i in range(cycle):
    if memo1[i] == memo2[i] and memo1[i] == 1:
        memo[i] = 1

cnt = sum(memo)

q, r = divmod(e, cycle)
res = q*cnt
for i in range(r):
    if memo[i]:
        res += 1
print(res)
0