修改题面
查看原帖
修改题面
511271
ダ月Nahida楼主2023/5/18 12:10
### 题目描述:

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 \le K \le 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 \le N \le 10^7)$.

FJ 给他的奶牛用二进制进行编号,每个编号恰好包含 $K$ 个 $1$ $(1 \le K \le 10)$,且必须是 $1$ 开头。FJ按升序编号,第一个编号是由 $K$ 个 $1$ 组成。

请问第 $N$$(1 \le N \le 10^7)$个编号是什么。

### 输入格式:

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

### 输出格式:

无。
2023/5/18 12:10
加载中...