20pts,求救悬关!

P3612 [USACO17JAN] Secret Cow Code S

Harley_Wu @ 2023-07-07 17:55:46


#include<bits/stdc++.h>
using namespace std;
string s;
long long len;
char work(long long x)
{
    len=s.length();
    for(int i=0;;i++)
    {
        s+=s[len-1];
        for(int j=0;j<=len;j++) s+=s[i];
        len=s.length();
        if(len>=x) return s[x-1];
    }
}
int main()
{
    long long n;
    cin>>s>>n;
    cout<<work(n);
    return 0;
}

|