1. What I learned
How to get the length of a string
In order to get the length of a string, ‘.length()’ can be used. ex) ‘STR.length()’
2. Code
#include <iostream>
using namespace std;
int main(void) {
int N;
cin >> N;
int num;
string str;
string result;
for (int i=0 ; i<N ; i++) {
cin >> num >> str;
result = "";
for (int j=0 ; j<str.length() ; j++) {
for (int k=0 ; k<num ; k++) {
result += str[j];
}
}
cout << result << '\n';
}
return 0;
}
3. Result
Runtime : 0 ms, Memory usage : 2024 KB
(Runtime can be different by a system even if it is a same code.)