You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
const int N = 110 ;
int a [ N ] ;
# define x first
# define y second
typedef pair < int , int > PII ;
int main ( ) {
int cnt = 0 ;
a [ 1 ] = + + cnt , a [ 128 ] = + + cnt ;
queue < PII > q ;
q . push ( { 1 , 128 } ) ;
while ( q . size ( ) ) {
auto t = q . front ( ) ;
q . pop ( ) ;
int mid = ( t . x + t . y ) > > 1 ;
a [ mid ] = + + cnt , a [ mid + 1 ] = + + cnt ;
if ( cnt > 32 ) break ;
q . push ( { t . x , mid } ) ;
q . push ( { mid + 1 , t . y } ) ;
}
// 1 3
// 1肯定是1, 2肯定是128
// 3可能是64, 也可能是65
// 4可能是64, 也可能是65
int s , t ;
cin > > s > > t ;
int p1 = 0 , p2 = 0 ;
for ( int i = 1 ; i < = 128 ; i + + )
if ( a [ i ] = = s ) {
p1 = i ;
break ;
}
for ( int i = 1 ; i < = 128 ; i + + )
if ( a [ i ] = = t ) {
p2 = i ;
break ;
}
if ( p1 = = 0 & & p2 = = 0 )
printf ( " 1 " ) ; //非种子选手可以分配到一组,最早是第一轮就相遇
else if ( ( p1 = = 0 & & p2 > 0 ) | | ( p1 > 0 & & p2 = = 0 ) )
printf ( " 1 " ) ; //有一个非种子
else { //两个都是种子
if ( p1 > p2 ) swap ( p1 , p2 ) ;
if ( p2 - p1 = = 1 )
printf ( " 1 " ) ;
else {
if ( p2 < 128 & & p2 % 2 = = 0 ) p2 - - ;
if ( p1 > 1 & & p1 % 2 = = 0 ) p1 + + ;
// cout << p1 << " " << p2 << endl;
if ( p2 - p1 > = 64 )
printf ( " 7 " ) ;
else if ( p2 - p1 > = 32 )
printf ( " 6 " ) ;
else if ( p2 - p1 > = 16 )
printf ( " 5 " ) ;
else if ( p2 - p1 > = 8 )
printf ( " 4 " ) ;
else if ( p2 - p1 > = 4 )
printf ( " 3 " ) ;
else if ( p2 - p1 > = 2 )
printf ( " 2 " ) ;
}
}
return 0 ;
}