36: binary classification, 36: binary classification

Source: Internet
Author: User

36: binary classification, 36: binary classification
36: binary classification

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
Description

If A positive integer is converted into A binary number, in this binary number, we call this binary number with the number of numbers 1 more than the number of numbers 0 A, otherwise it is called B.

For example:

(13) 10 = (1101) 2, where the number of 1 is 3, and the number of 0 is 1, this number is called the number of class;

(10) 10 = (1010) 2, where the number of 1 is 2, and the number of 0 is 2, it is called the number of class B;

(24) 10 = (11000) 2. If the number of 1 is and the number of 0 is 3, this number is called the number of Class B;

Program Requirements: Obtain 1 ~ The number of classes A and B in 1000 (including 1 and 1000.

 

Input
None.
Output
A row contains two integers, namely the number of Class A and Class B, separated by A single space.
Sample Input
(None)
Sample output
(Not available)
Source
Topic 3 of NOIP1995 semi-finals popularity Group
1 # include <iostream> 2 using namespace std; 3 int alei; 4 int blei; 5 int main () 6 {7 for (int I = 1; I <= 1000; I ++) 8 {9 int yi = 0; 10 int ling = 0; 11 int now = I; // record I value 12 while (now! = 0) 13 {14 int r = now % 2; 15 if (r = 1) yi ++; 16 else if (r = 0) ling ++; 17 now = now/2; 18} 19 if (yi> ling) alei ++; 20 else blei ++; 21} 22 cout <alei <"" <blei; 23 return 0; 24}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.