yr是yr @ 2023-12-01 11:08:11
#include <math.h>
typedef long long ll;
ll n;
char arr[35];
ll len = 0;
void solu(ll x);
void shuchu(ll x, int y);
void solu(ll x)
{
ll i = 1;
ll num1, num2;
int qujian = 2;
if(x <= len)
{
printf("%c", arr[x]);
return;
}
while(1)
{
num1 = len*i;
num2 = len*i*2;
if(x > num1 && x <= num2)
{
break;
}
else
{
i *= 2;
qujian++;
}
}
shuchu(x, qujian);
}
void shuchu(ll x, int y)
{
if(y == 1)
{
printf("%c", arr[x]);
return;
}
x = x - len*pow(2, y - 2) - 1;
solu(x);
return;
}
int main()
{
scanf("%s", arr);
scanf("%lld", &n);
while(arr[len] != '\0')
{
len++;
}
for(int i = len;i >= 0;i--)
{
arr[i + 1] = arr[i];
}
solu(n);
return 0;
}
by yr是yr @ 2023-12-01 11:09:47
第一个头文件是<stdio.h>,不知道为啥不见了
by tqldam @ 2023-12-01 14:40:38
你错误的测试点的样例是
ABCDEFGHIJKLMNOPQRSTUVWXYZ 99999999999999999
正确答案是
D
你给出的代码的结果是
G
by reeceli @ 2023-12-18 11:20:29
@yr是yr @yr是yr 电脑里的pow函数在这个级别会有较大误差哦,所以应该自己写一个pow函数才更加精确
by return_second @ 2024-01-20 11:03:45
用<<
位运算