PivotOJ

Cow IDs

시간 제한: 1000ms메모리 제한: 128MB출처: USACO February 2012 Contest, SilverBOJ 5900

문제

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.

출력

    힌트

    Input Details

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

    예제

    예제 1

    입력
    7 3
    출력
    10110
    코드를 제출하려면 로그인하세요.