当前位置:网站首页>51nod 1413 power binary
51nod 1413 power binary
2022-07-18 03:19:00 【51CTO】
A decimal integer is called a power binary , When expressed in decimal, it is only represented by 0 or 1 form . for example 0,1,101,110011 It's all power binary and 2,12,900 No .
When given a n When , Calculate the minimum number of power binaries you need to add to get n.
Input
A single set of test data . The first line gives an integer n (1<=n<=1,000,000)
Output
Output the answer in one line .
Input Example
9
Output Example
9
At the beginning of doing this, I took out my ancestral DFS, But it didn't come out .
Then observe the data , Find that what you give n Everyone in the group took it out , Then find someone to follow n Power binary numbers of the same length ,n If each bit of is greater than 1, The bit of this binary number is equal to 1, Or equal to 0, Then this number can definitely be added to n Of , then n Subtract this number , Repeat these steps , You can figure it out .
The code is as follows :
边栏推荐
猜你喜欢

中國人力資源數字化生態圖譜-靈活用工市場
MySQL multi table query, detailed to this extent, haven't you learned yet?, Including display inner connection, implicit inner connection, left connection, right connection and sub query in inner and

Analyze the meaning of "collaboration" in collaborative office, and how can digital office easily "solve the problem"?

ModuleNotFoundError: No module named ‘fake_ useragent‘

Fuxin software appeared at the 2022 national chemical enterprise digital intelligence transformation and Development Forum

RobotFramework进阶(一)集成Pycharm及UI自动化用例编写

RobotFramework进阶(三)集成Jenkins运行自动化用例

"The faster the code is written, the slower the program runs"

红外遥控氛围灯触摸芯片-DLT8SA15A-杰力科创
![[the road of Exile - Chapter 1]](/img/f0/faf72ee2a4199d43cc92137542c86c.png)
[the road of Exile - Chapter 1]
随机推荐
LNMP architecture PHP installation
Accenture's 22 year technology outlook report: digital transformation will usher in the next decade
ClickPaaS马俊:模型驱动的低代码平台实践
The bull and bear cycle of the encryption market; Debate on the definition of NFT
Traverse the file (txt) under the folder and delete the last line
字符串拼接
Explication détaillée de la méthode d'interruption du fil
Redis 过期的数据会被立马删除么?大有玄机
RobotFramework进阶(一)集成Pycharm及UI自动化用例编写
[cloud native] development of terrain addon based on kubevera Huawei cloud
第2讲 Hi3861的WiFi实验-API-1
埃森哲22年《技术展望》报告:数字化转型将迎来下一个十年
PD-Server GRPC 接口图解
TiKV & TiFlash 加速复杂业务查询
Hcip review (2)
【开发教程17】AI语音人脸识别(会议记录仪/人脸打卡机)-AI人脸注册认证与识别
Tencent celebrities share | Tencent alluxio (DOP) landing and Optimization Practice in the financial scene
什么是主动元数据?为什么Gartner预测它是元数据管理的新方向
torch.max()和numpy.max()使用辨析
Hcip notes (2)