HBC257292020Binary Number题解

一个忧伤的美男子 算法基础篇 32 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
is either 0 or 1. Particularly, n-digit binary number can be written as. This time, to test your mastery of binary numbers, Leg Han raises a problem to you.Among all n-digit binary numbers whose amount of 1 is m, please print the k-th smallest one.

    As a programmer, you are probably familiar with the binary representation of integers. That is, write an integer x as sum a_{i}2^{i} ∑a i ​ 2 i , where each a_{i} a i ​ is either 0 or 1. Particularly, n-digit binary number can be written as sum_{i = 0}^{n-1} a_{i}2^{i} ∑ i=0 n−1 ​ a i ​ 2 i , in which a_{n-1} a n−1 ​ must equal to 1.     This time, to test your mastery of binary numbers, Leg Han raises a problem to you.     Among all n-digit binary numbers whose amount of 1 is m, please print the k-th smallest one.     It is guaranteed that k is legal.

HBC257292020Binary Number题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
成为编程大师,不再是梦想!全网最全C++题库,助您开启编程新篇章。

标签: HBC257292020Binary Number题解