当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
Sort the first n integers 1,2,3,...,n-1,n in lexicographical order, and the k-th integer is known as m. Can you tell me the smallest n?
For example,when n=11, the order is 1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9. And the 4-th integer is 2.
The input contains many test cases ended with EOF. Each test case contains only one line of two integers, k and m.
1 ≤ k, m ≤ 10^9
For each test case output the smallest n in a single line. If there is no such n, just output 0.
4 2 2 1 1000 25
11 0 1831
时间上限 | 内存上限 |
1000 | 65536 |