愣是发现不了问题,故问,求大佬指正
查看原帖
愣是发现不了问题,故问,求大佬指正
714500
Tennif_hxz楼主2023/7/1 17:09
#include <bits/stdc++.h>
using namespace std;

int len(string s){
	int j=0;
	while(s[j]) j++;
	return j;
}

int main(){
	ios::sync_with_stdio (0);
	cin.tie (0);cout.tie (0);
	
	string s;
	long long num=0;
	cin>>s>>num;
	
	long long l=len(s);
	long long ll=len(s);
	
	while(l<num)
	{
		l*=2;
	}
	
	while(num>ll)
	{
		if(num<l){
			l/=2;
		}
		else num-=(l+1);
		if(num=0) num=l;
	}
	cout<<s[num-1];
	return 0;
}

求指正

2023/7/1 17:09
加载中...