[USACO 2012 Feb S]Cow IDs
题号:NC24311
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

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).

输入描述:

* Line 1: Two space-separated integers, N and K.

输出描述:

* Line 1: please determine the Nth label he should assign (1 <= N <= 10^7).
示例1

输入

复制
7 3

输出

复制
10110

说明

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