当前位置:网站首页>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; }
边栏推荐
- Shell script three swordsman sed
- Sequence list and linked list
- Global and Chinese market of process beer equipment 2022-2028: Research Report on technology, participants, trends, market size and share
- [software testing] you haven't mastered these real interview questions of big companies?
- be based on. NETCORE development blog project starblog - (14) realize theme switching function
- 查询效率提升10倍!3种优化方案,帮你解决MySQL深分页问题
- Global and Chinese markets for instant saliva testing devices 2022-2028: Research Report on technology, participants, trends, market size and share
- It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
- Wechat official account and synchronization assistant
- Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
猜你喜欢
Windos10 reinstallation system tutorial
The super fully automated test learning materials sorted out after a long talk with a Tencent eight year old test all night! (full of dry goods
MySQL 8.0.12 error: error 2013 (HY000): lost connection to MySQL server during query
It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。
be based on. NETCORE development blog project starblog - (14) realize theme switching function
2-redis architecture design to use scenarios - four deployment and operation modes (Part 2)
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
在寻求人类智能AI的过程中,Meta将赌注押向了自监督学习
Joint examination of six provinces 2017
随机推荐
Oracle database knowledge points that cannot be learned (III)
打印菱形图案
system. Exit (0) and system exit(1)
删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
Future source code view -juc series
7.1 学习内容
gslb(global server load balance)技术的一点理解
be based on. NETCORE development blog project starblog - (14) realize theme switching function
Detailed explanation of the relationship between Zhongtai, wechat and DDD
Global and Chinese market of glossometer 2022-2028: Research Report on technology, participants, trends, market size and share
Design of database table foreign key
1-Redis架构设计到使用场景-四种部署运行模式(上)
The super fully automated test learning materials sorted out after a long talk with a Tencent eight year old test all night! (full of dry goods
在寻求人类智能AI的过程中,Meta将赌注押向了自监督学习
The FISCO bcos console calls the contract and reports an error does not exist
Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
From functional testing to automated testing, how did I successfully transform my salary to 15K +?
HR disgusted interview behavior
手机异步发送短信验证码解决方案-Celery+redis