| Final round of the X Vologda Regional Informatics Olympiad for the Governors Prize 2025, grades 9-10 |
|---|
| Finished |
Vasya wrote down $$$n$$$ consecutive positive integers on a piece of paper. In total, there are $$$k$$$ digits written down. What number did Vasya write first?
Two integers $$$n$$$ and $$$k$$$ are given, each on a separate line ($$$1 \le n \le 10^{17}$$$, $$$1 \le k \le \min(18 \cdot n, 10^{18})$$$).
Output the number that was written first. If there are multiple correct answers, output the smallest one. If there are no solutions, output -1.
910
2
21
-1
Grading System.
Subtask 1 (up to 28 points): $$$n \le 100$$$, $$$k \le \min(3 \cdot n, 10^3)$$$.
Subtask 2 (up to 36 points): $$$n \le 10^6$$$, $$$k \le \min(7 \cdot n, 10^7)$$$.
Subtask 3 (up to 36 points): $$$n \le 10^{17}$$$, $$$k \le \min(18 \cdot n, 10^{18})$$$.
Note: The input data and answer in the third subtask may not fit into a 32-bit integer type, it is recommended to use a 64-bit type (long long in C++, long in Java and C#, int64 in Pascal). In Python, no additional actions are required.
| Name |
|---|


