20分超时求调

P3612 [USACO17JAN] Secret Cow Code S

awdfkewd @ 2024-08-22 15:10:45

#include<bits/stdc++.h>
using namespace std;
string s,a;
long long n;
string temp;
int main(){
    cin>>a>>n;
    s=" ";
    s+=a;
    while((long long)s.length()-1<n){
        for(long long unsigned int i=0;i<a.length()-1;i++){
            swap(a[i],a[i+1]);
        }
        s+=a;
    }
    cout<<s[n];
}

by circben @ 2024-09-23 15:02:56

题目理解错了,是操作拼接后的字符串,不是来回操作a


|