题解:AT_genocon2021_c Practice 3

· · 题解

题意

给定 n 个字符串,要求给每个字符串添加一些 -,使字符串对齐。

思路

注意到,字符串的长度不超过 750,直接以 750 为基准值,补全即可。

代码

#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
    cin>>n;
    while(n--){
        cin>>s;
        cout<<s;
        for(int i=1;i<=750-s.size()+1;i++){
            cout<<"-";
        }
        cout<<endl;
    }
    return 0;
}