ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > Bil-203 Praktika 23.12.2021 > задача:


5. Bitsorting

Bil-203 Praktika 23.12.2021

Старт: 23.дек.2021 в 08:05:00
Финиш: 26.дек.2021 в 23:59:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (1)

Задачи турнира

• 1. Кызыктуу сан
• 2. Жайлоого баруу
• 3. Возрастающая последовательно...
• 4. Кайрадан спираль
• 5. Bitsorting

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Автор: Павел Кузнецов, ПГУ.

For the set of all non-negative integers let's introduce the following order relation: let's admit that number A is less than number B in two cases:

• When the binary notation of A has fewer "ones" than B has.
• When the binary notation of A contains the same amount of "ones" that B has, and A is less than B in usual meaning.

Now sort out the set of integers, from 0 to N inclusive, in ascending order using this new order relation. Your task is to find the number, placed in position K. The numeration of the positions begins from 1.

Input
The first line of the input contains the integers N and K (0 ≤ N ≤ 1016; 1 ≤ KN+1).
Output
The output should contain one number which is the answer to the question.

Input 1 Output 1
10 7
5

Comment on the example: the integers from 0 to 10 will be sorted in the following way: 0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 7.

Для отправки решений необходимо выполнить вход.

www.contester.ru