ZJANS

b759. 我明明就有說過= =

Medium Last Update: 2026/01/20
cpp

解法一

✅ 完整代碼

評分結果(參考) : AC (22ms, 340KB)

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    
    int l = s.size();
    s += s;
    
    for(int i=0; i<l; i++){
        for(int j=0; j<l; j++){
            cout << s[i+j];
        }
        cout << "\n";
    }
    
    return 0;
}
IO 優化 - putchar_unlocked

✅ 完整代碼

評分結果(參考) : AC (22ms, 340KB)

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    
    int l = s.size();
    s += s;
    
    for(int i=0; i<l; i++){
        for(int j=0; j<l; j++){
            putchar_unlocked(s[i+j]);
        }
        putchar_unlocked('\n');
    }
    
    return 0;
}