알고리즘

[알고리즘] 백준 11944 - NN (C++)

blueberrysoda 2024. 11. 23. 23:49

[문제 링크] : https://www.acmicpc.net/problem/11944

#include <iostream>
using namespace std;

int main(){
    string S;
    int M;

    cin >> S >> M;
    int N = stoi(S);
    string Ans = "";

    for(int i=0; i<N; i++){
        Ans += S;
    }

    if(Ans.size() > M){
        cout << Ans.substr(0, M) << "\n";
    }
    else{
        cout << Ans << "\n";
    }
    return 0;
}