英语翻译13

https://acs.jxnu.edu.cn/external/gym/doc/GYM100002A.doc

Let us consider the set of integer numbers between 1 and N inclusive. Let us order them lexicographically (i. e. like in the vocabulary), for example, for N = 11 the order would be: 1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9.

Let us denote the position of the number K in this ordering as QN,K. For example, Q11,2 = 4. Given numbers K and M find the smallest N such that QN,K = M.

Input

Input file contains two integer numbers K and M (1 ≤ K, M ≤ 109) separated by a space.

Output

If such N that QN,K = M exists then write to the output file the smallest such N, otherwise write 0.

Sample inputs and outputs

amusing.in

amusing.out

2 4

11

2 1

0

100000001 1000000000

100000000888888879

1000000000 11

0

中文翻译:

让我们考虑1和N之间的整数集合。例如,对于N=11,顺序是:1,10,11,2,3,4,5,6,7,8,9。让我们把数K在这个序中的位置表示为QN,K,例如,Q11,2=4,给定数K和M,找到最小的N,使得QN,K=M。

输入:

输入文件包含由空格分隔的两个整数K和M(1≤K,M≤109)

输出:

如果存在QN,K=M,则将最小的N写入输出文件,否则写入0。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值