{"problem":{"name":"Make Divisible","description":{"content":"You are given positive integers $A$ and $B$. Find the minimum value of $X+Y$ for non-negative integers $X$ and $Y$ such that $B+Y$ is a multiple of $A+X$. You have $T$ test cases to solve.","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc150_b"},"statements":[{"statement_type":"Markdown","content":"You are given positive integers $A$ and $B$.\nFind the minimum value of $X+Y$ for non-negative integers $X$ and $Y$ such that $B+Y$ is a multiple of $A+X$.\nYou have $T$ test cases to solve.\n\n## Constraints\n\n*   $1 \\leq T \\leq 100$\n*   $1 \\leq A,\\ B \\leq 10^9$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$T$\n$\\mathrm{case}_{1}$\n$\\mathrm{case}_{2}$\n$\\vdots$\n$\\mathrm{case}_{T}$\n\nEach case is in the following format:\n\n$A$ $B$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc150_b","tags":[],"sample_group":[["5\n11 23\n8 16\n4394 993298361\n95392025 569922442\n8399283 10293","2\n0\n65\n2429708\n8388990\n\nFor the first test case, if we let $X=1$ and $Y=1$, then $B+Y=24$ will be a multiple of $A+X=12$. Here, we have $X+Y=2$, and there is no way to make $X+Y$ smaller, so the answer is $2$.\nFor the second test case, if we let $X=0$ and $Y=0$, then $B+Y=16$ will be a multiple of $A+X=8$."]],"created_at":"2026-03-03 11:01:14"}}