Codeforces Round 653 (Div. 3)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1374 Codeforces Round 653 (Div. 3) FINISHED False 7200 143997911 June 28, 2020, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 55517 ) A Required Remainder PROGRAMMING math

B'You are given three integers x, y and n . Your task is to find the maximum integer k such that 0 <= k <= 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 <= t <= 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 <= x <= 10^9;~ 0 <= y < x;~ y <= n <= 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 <= k <= n and k bmod x = y . It is guaranteed that the answer always exists. In the first test case of the example, the answer is 12339 = 7 cdot 1762 + 5 (thus, 12339 bmod 7 = 5 ). It is obvious that there is no greater integer not exceeding 12345 which has the remainder 5 modulo 7 . '...

Tutorials

79517

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
85379834 Gassa A June 28, 2020, 4:28 p.m. OK D TESTS 20 77 4812800

remove filters

Back to search problems