A_chicken_boy @ 2023-07-31 17:02:21
样例可以过,不知道错哪了,dalao们,帮帮我
#include <bits/stdc++.h>
using namespace std ;
string s ;
int ll ;
int f ;
int ans ;
void cow ( long long , long long ) ;
int main ( ){
long long n ;
cin >> s ;
cin >> n ;
int l = s.size ( ) ;
ll = l ;
int cnt = 1 ;
if ( n <= l ){
cout << s[n-1] ;
return 0 ;
}
for ( int i = 1 ; ; ++i ){
if ( l * 2 < n ){
cnt ++;
l*=2;
}else {
cnt++;
l *= 2 ;
break ;
}
}
cow ( n , l );
cout << s[ans-1];
return 0 ;
}
void cow ( long long n , long long l ){
if ( n <= ll ) {
//cout << "return " ;
ans = n ;
f = 1 ;
//cout << ll << " <-ll " ;
//cout << ans << "return \n";
}
if ( n - l / 2 - 1 > 0 && f == 0 ){
//cout << "> " << n - l/2 - 1 << " " << l/2 << endl ;
cow ( n - l/2 - 1 , l / 2 ) ;
}
if ( n - l/2 - 1 == 0 && !f ) {
//cout << "== " << n/2 << " " << n /2 <<endl ;
cow ( l / 2 , l/2) ;
}
}