CS Academy Round #38: B. Attack and Speed
solution
制約を式に直すと答えt∈NはA+Xt=S+Y(K−t)∧0≤t≤K。解くだけ。O(1)。
implementation
#!/usr/bin/env python3
import random
a, s, k, x, y = map(int, input().split())
num = s - a + k * y
den = x + y
result = -1
if num % den == 0 and 0 <= num // den <= k:
result = num // den
print(result)