newton/solutions/required_remainder.py

12 lines
197 B
Python
Raw Normal View History

2025-01-11 11:41:29 +00:00
t = int(input())
for _ in range(t):
x, y, n=[int(x) for x in input().split()]
k=n % x
if k > y:
print(n-k+y)
elif k == y:
print(n)
else:
print(n-k-x+y)