当前位置:网站首页>All in one 1412: binary classification
All in one 1412: binary classification
2022-07-04 00:46:00 【Studying hard】
【 Title Description 】
If you convert a positive integer to a binary number , In this binary number , We will count 1 The number of is more than the number 0 This kind of binary number is called A Class number , Otherwise, it is called B Class number .
for example :
(13)10=(1101)2, among 1 The number of 3,0 The number of 1, This number is called A Class number ;
(10)10=(1010)2(, among 1 The number of 2,0 The number of is also 2, Call this number B Class number ;
(24)10=(11000)2, among 1 The number of 2,0 The number of 3, This number is called B Class number ;
Procedural requirements : Find out 1∼1000 In ( Include 1 And 1000), All A、B The number of two kinds of numbers .
【 Input 】
( nothing )
【 Output 】
a line , Contains two integers , Namely AA Number of classes and BB Number of classes , Separate them with a single space .
【 sample input 】
( nothing )【 sample output 】
( nothing )#include<stdio.h> int num1 = 0, num2 = 0; void gettwo(int n) { int i; int count = 0, num = 0; while (1) { i = n % 2; n /= 2; if (i == 1) { count++; } if (i == 0) { num++; } if (n == 0) { break; } } if (count > num) { num1++; } else { num2++; } } int main() { int i; for (i = 1; i <= 1000; i++) { gettwo(i); } printf("%d %d", num1, num2); return 0; }
边栏推荐
- URL (data:image/png; Base64, ivborw0k... Use case
- Anomalies seen during the interview
- Qtcharts notes (V) scatter diagram qscatterseries
- Data storage - interview questions
- Stock price forecast
- 功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
- How to set the response description information when the response parameter in swagger is Boolean or integer
- CesiumJS 2022^ 源码解读[8] - 资源封装与多线程
- 删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
- MySQL winter vacation self-study 2022 12 (1)
猜你喜欢

Pytest unit test framework: simple and easy to use parameterization and multiple operation modes

MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query

Introduction to unity shader essentials reading notes Chapter III unity shader Foundation

中电资讯-信贷业务数字化转型如何从星空到指尖?

Unity Shader入门精要读书笔记 第三章 Unity Shader基础
![[prefix and notes] prefix and introduction and use](/img/a6/a75e287ac481559d8f733e6ca3e59c.jpg)
[prefix and notes] prefix and introduction and use

Function: store the strings entered in the main function in reverse order. For example, if you input the string "ABCDEFG", you should output "gfedcba".

Cloud dial test helps Weidong cloud education to comprehensively improve the global user experience

be based on. NETCORE development blog project starblog - (14) realize theme switching function
![[C language] break and continue in switch statement](/img/ae/5967fefcf3262c9d3096e5c7d644fd.jpg)
[C language] break and continue in switch statement
随机推荐
It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
Future source code view -juc series
For loop
swagger中响应参数为Boolean或是integer如何设置响应描述信息
手机异步发送短信验证码解决方案-Celery+redis
A dichotomy of Valentine's Day
老姜的特点
功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
Struct in linked list
What is the potential of pocket network, which is favored by well-known investors?
【.NET+MQTT】.NET6 环境下实现MQTT通信,以及服务端、客户端的双边消息订阅与发布的代码演示
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
Function: find the sum of the elements on the main and sub diagonal of the matrix with 5 rows and 5 columns. Note that the elements where the two diagonals intersect are added only once. For example,
UTS | causal reasoning random intervention based on Reinforcement Learning
Global and Chinese market of underwater bags 2022-2028: Research Report on technology, participants, trends, market size and share
使用dnSpy对无源码EXE或DLL进行反编译并且修改
PMP 考试常见工具与技术点总结
我管你什么okr还是kpi,PPT轻松交给你
Wechat official account and synchronization assistant
Cesiumjs 2022^ source code interpretation [8] - resource encapsulation and multithreading