Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Amusing Numbers
Description 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 Q _{N,K}. For example, Q_{11,2} = 4. Given numbers K and M find the smallest N such that Q_{N,K} = M.
Input Input contains two integer numbers K and M (1 <= K, M <= 10 ^{9}) separated by a space.Output If such N that Q _{N,K} = M exists then write to the output the smallest such N, otherwise write 0.Sample Input 100000001 1000000000 Sample Output 100000000888888879 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator