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}