結果

問題 No.1486 ロボット
ユーザー DrDrpilotDrDrpilot
提出日時 2022-02-23 13:17:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 8,332 KB
最終ジャッジ日時 2023-09-14 05:32:03
合計ジャッジ時間 3,022 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,328 KB
testcase_01 AC 16 ms
8,268 KB
testcase_02 AC 16 ms
8,248 KB
testcase_03 AC 16 ms
8,112 KB
testcase_04 AC 15 ms
8,160 KB
testcase_05 AC 15 ms
8,328 KB
testcase_06 AC 332 ms
8,276 KB
testcase_07 AC 349 ms
8,232 KB
testcase_08 AC 166 ms
8,156 KB
testcase_09 AC 16 ms
8,172 KB
testcase_10 AC 39 ms
8,276 KB
testcase_11 AC 37 ms
8,312 KB
testcase_12 AC 18 ms
8,156 KB
testcase_13 AC 16 ms
8,276 KB
testcase_14 AC 170 ms
8,168 KB
testcase_15 AC 41 ms
8,308 KB
testcase_16 AC 68 ms
8,276 KB
testcase_17 AC 85 ms
8,332 KB
testcase_18 AC 57 ms
8,140 KB
testcase_19 AC 33 ms
8,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b,c,d,e=map(int,input().split())
from math import gcd
lcm=(a+b)*(c+d)//gcd(a+b,c+d)
rob1=[0,a];rob2=[0,c]
now=0
cnt_cycle=0
for now in range(lcm):
    if rob1[0]<=now<rob1[1] and rob2[0]<=now<rob2[1]:
        cnt_cycle+=1
    if rob2[1]<=now:
        rob2=[rob2[0]+c+d,rob2[1]+c+d]
    if rob1[1]<=now:
        rob1=[rob1[0]+a+b,rob1[1]+a+b]
ans=e//lcm*cnt_cycle
amari=e%lcm
rob1=[0,a];rob2=[0,c]
for now in range(amari):
    if rob1[0]<=now<rob1[1] and rob2[0]<=now<rob2[1]:
        ans+=1
    if rob2[1]<=now:
        rob2=[rob2[0]+c+d,rob2[1]+c+d]
    if rob1[1]<=now:
        rob1=[rob1[0]+a+b,rob1[1]+a+b]
print(ans)
0