-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1029A.cpp
38 lines (36 loc) · 1 KB
/
1029A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "bits/stdc++.h"
using i64 = long long int;
using namespace std;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define inarr(a,n) for(int i = 0; i < n; ++i) cin >> a[i];
#ifndef ONLINE_JUDGE
#define db(x) cerr << #x <<" = " << x << "\n";
#else
#define db(...)
#endif
//
void solve(){
int n,k;cin >> n >> k;
k--; string s; cin >> s;
string start = "";
for(int i=1;i<n;++i){
string a,b;
a = s.substr(0,i);
b = s.substr(n-i,i);
if(a != b)break;
start = a;
}
string last = s.substr(sz(start),n - sz(start));
cout << s;
while(k--) cout << last;
}
int main(){
cin.tie(nullptr);cout.tie(nullptr);ios::sync_with_stdio(false);
int testt = 1;
// cin >> testt;
for (int i = 0; i < testt; ++i) {
// cout << "Case #" << i << ": ";
solve();
}
}