Задача Amusing Numbers

Файл входного файла: amusing.in
Файл выходного файла: amusing.out
Ограничение по памяти: 64 MB
Ограничение по времени: 2 s

Описание

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 file contains two integer numbers K and M (1 ≤ K, M ≤ 10 9 ) separated by a space.

Формат выходных данных

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

Примеры:

ввод вывод

2 4

11

2 1

0

100000001 1000000000

100000000888888879

1000000000 11

0

Added: admin
Difficulty: 0.997816934352
Accepted: 1
Submitted: 3
Analyze this Discuss

Обсуждение:

Начать обсуждение:

Powered by django, eJudge.