8426: Cow IDs

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

Being a secret computer geek, Farmer John labels all of his cows with binary numbers. However, he is a bit superstitious, and only labels cows with binary numbers that have exactly K "1" bits (1 <= K <= 10). The leading bit of each label is always a "1" bit, of course. FJ assigns labels in increasing numeric order, starting from the smallest possible valid label -- a K-bit number consisting of all "1" bits. Unfortunately, he loses track of his labeling and needs your help: please determine the Nth label he should assign (1 <= N <= 10^7).


作为一个神秘的电脑极客,农夫约翰使用二进制数字给他的所有奶牛编号。

 

但是,他有点迷信,他只使用刚好包含 K 1 的二进制数给奶牛编号。

 

当然,每个编号的前导位始终是 1

 

约翰从最小的有效编号(K 1 构成的二进制数)开始,以递增的数字顺序给每头奶牛分配编号。

 

请确定他应该分配的第 N 个编号。


输入格式

* Line 1: Two space-separated integers, N and K.
共一行,包含两个整数 N 和 K。

输出格式

Among all binary numbers containing exactly 3 "1" bits, FJ wants to output the 7th in increasing sorted order.

输出第 N 个编号。


输入样例 复制

7 3

输出样例 复制

10110

数据范围与提示

数据范围

1N107,

1K10