40分,(不是string模拟)

P3612 [USACO17JAN] Secret Cow Code S

sd_JC @ 2023-11-26 22:37:45

#include<bits/stdc++.h>
using namespace std;
vector<long long>a;
int main(){
    string s;
    long long n;
    cin>>s;
    for(long long i=0;i<s.size();i++)
        a.push_back(s[i]);
    cin>>n;
    while(1){
        if(a.size()>=n)break;
        vector<long long>aa;
        aa.push_back(a[a.size()-1]);
        for(long long i=0;i<a.size()-1;i++)
            aa.push_back(a[i]);
        for(long long i=0;i<aa.size();i++)
            a.push_back(aa[i]);
    }
    cout<<char(a[n-1]);
    return 0;
}

记录详情


by sd_JC @ 2023-11-27 22:12:41

@C20252323tzy @Cczzyy20150005帮帮我


|