結果

問題 No.1486 ロボット
コンテスト
ユーザー lam6er
提出日時 2025-03-20 21:04:56
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 525 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 219 ms
コンパイル使用メモリ 96,308 KB
実行使用メモリ 83,680 KB
最終ジャッジ日時 2026-07-07 12:45:20
合計ジャッジ時間 2,954 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math

A, B, C, D, E = map(int, input().split())

T1 = A + B
T2 = C + D

def compute_lcm(a, b):
    return a * b // math.gcd(a, b)

lcm = compute_lcm(T1, T2)

# Compute the overlap in one full LCM cycle
S = 0
for t in range(lcm):
    r1 = t % T1
    r2 = t % T2
    if r1 < A and r2 < C:
        S += 1

q = E // lcm
remainder = E % lcm

# Compute the overlap in the remainder part
R = 0
for t in range(remainder):
    r1 = t % T1
    r2 = t % T2
    if r1 < A and r2 < C:
        R += 1

total = q * S + R
print(total)
0