307560: CF1374A. Required Remainder
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Required Remainder
题意翻译
### 题目描述 输入$x,y,n(2\le x\le10^9,0\le y<x,y\le n\le10^9)$ 求满足$k\bmod x=y\ (0\le k\le n)$的$k$的最大值 多组数据, 数据组数$1\le t\le5\cdot10^4$ ### 输入格式 第一行,一个数$t$ 第$2$到第$t+1$行, 每行一组$x,y,n$ ### 输出格式 一行一个满足条件的非负整数$k$ 可以证明在给定的条件下, $k$一定存在题目描述
You are given three integers $ x, y $ and $ n $ . Your task is to find the maximum integer $ k $ such that $ 0 \le k \le n $ that $ k \bmod x = y $ , where $ \bmod $ is modulo operation. Many programming languages use percent operator % to implement it. In other words, with given $ x, y $ and $ n $ you need to find the maximum possible integer from $ 0 $ to $ n $ that has the remainder $ y $ modulo $ x $ . You have to answer $ t $ independent test cases. It is guaranteed that such $ k $ exists for each test case.输入输出格式
输入格式
The first line of the input contains one integer $ t $ ( $ 1 \le t \le 5 \cdot 10^4 $ ) — the number of test cases. The next $ t $ lines contain test cases. The only line of the test case contains three integers $ x, y $ and $ n $ ( $ 2 \le x \le 10^9;~ 0 \le y < x;~ y \le n \le 10^9 $ ). It can be shown that such $ k $ always exists under the given constraints.
输出格式
For each test case, print the answer — maximum non-negative integer $ k $ such that $ 0 \le k \le n $ and $ k \bmod x = y $ . It is guaranteed that the answer always exists.
输入输出样例
输入样例 #1
7
7 5 12345
5 0 4
10 5 15
17 8 54321
499999993 9 1000000000
10 5 187
2 0 999999999
输出样例 #1
12339
0
15
54306
999999995
185
999999998