金钢猪 @ 2021-02-02 14:38:52
#include<stdio.h>
#include<string.h>
long long n;
long long length,len;
char s[35];
void slove(long long leng,long long nth){
if(nth <= len){
printf("%c",s[nth-1]);
return ;
}
long long half = leng/2;
long long new_nth = nth-half-1;
slove(half,new_nth);
}
int main(){
scanf("%s",s);
scanf("%lld",&n);
len = strlen(s);
length = len;
while(length < n){
length*=2;
}
slove(length,n);
return 0;
}
by 金钢猪 @ 2021-02-02 14:39:47
加入0特判断的情况还是一样的