cswork / OA打开练习工作台

Deutsche BankOA #2

Give Minimum Sum

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)位运算

Give the minimum sum of (x+y) such that A and B are given and (A+x) should be multiple of (B+y).

Example 1

Input:

A = 8
B = 16

Output:

0

Explanation: Educated guess - Since A is already a multiple of B, no additional sum is needed. Therefore, the answer is 0.

Example 2

Input:

A = 7
B = 37

Output:

4

Explanation: Educated guess - The minimum sum of (x+y) to make (A+x) a multiple of (B+y) is 4. This can be achieved by setting x = 3 and y = 1, making (A+x) = 10 and (B+y) = 38, where 10 is a multiple of 38.