{"problem":{"name":"[EC Final 2022] Best Carry Player 2","description":{"content":"Given a positive integer $x$, find the minimum positive integer $y$ such that the number of $\\textbf{carries}^1$ of $x+y$ is exactly $k$. We adds numbers $\\textbf{by column addition in base-ten}$, ju","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":3000,"memory_limit":1048576},"difficulty":{"LuoguStyle":"P5"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP9718"},"statements":[{"statement_type":"Markdown","content":"Given a positive integer $x$, find the minimum positive integer $y$ such that the number of $\\textbf{carries}^1$ of $x+y$ is exactly $k$.\n\nWe adds numbers $\\textbf{by column addition in base-ten}$, just like what we normally do in primary school. For example, there are two carries in the following addition.\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/pfnper3r.png)\n\n$^1$ which means ``进位`` in Chinese.\n\n## Input\n\nThe first line contains an integer $T$ $(1\\leq T\\leq 10^5)$ $-$ the number of test cases.\n\nFor each test case, the first line contains two integers $x, k$ $(1\\leq x < 10^{18}, 0\\leq k \\leq 18)$.\n\n## Output\n\nFor each test case, output one integer representing the answer in one line. If there is no solution, output $-1$ instead.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"LGP9718","tags":["2022","O2优化","数位 DP","ICPC","EC Final"],"sample_group":[["4\n12345678 0\n12345678 5\n12345678 18\n990099 5","1\n54322\n999999999987654322\n9910"]],"created_at":"2026-03-03 11:09:25"}}