Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
159711 | 梁乃元 | 二进制分类 | C++ | Accepted | 100 | 1 MS | 248 KB | 546 | 2024-07-30 18:14:56 |
# include <bits/stdc++.h> using namespace std ; bool cmp ( int x ) { int cnt1 = 0 , cnt2 = 0 ; while ( x > 1 ) { int t = x % 2 ; x >>= 1 ; if ( t ) { cnt1 ++ ; } else { cnt2 ++ ; } } if ( x ) { cnt1 ++ ; } else { cnt2 ++ ; } return cnt1 > cnt2 ; } int main ( ) { int a , b , ca = 0 , cb = 0 ; cin >> a >> b ; for ( int i = a ; i <= b ; i ++ ) { if ( cmp ( i ) ) { ca ++ ; } else { cb ++ ; } } cout << ca << ' ' << cb << endl ; return 0 ; }