-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSPOJ10373.cc
More file actions
40 lines (37 loc) · 775 Bytes
/
SPOJ10373.cc
File metadata and controls
40 lines (37 loc) · 775 Bytes
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
39
40
// SPOJ 5132: Hello Kitty
// http://www.spoj.com/problems/HELLOKIT/
//
// Solution: String, Ad-Hoc
//
// Remark. This is an ambiguous problem.
// For the input 'abab 1', I cannot decide
// which is the collect output:
// abab
// baba
// or
// abab
// baba
// abab <- same as first line
// baba
//
// Following code produce the later output.
//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
void solve(string s, int k) {
int n = s.size();
for (int i = 0; i < n; ++i) {
for (int j = 0; j < k; ++j)
cout << s.substr(i,n-i) << s.substr(0,i);
cout << endl;
}
}
int main() {
string s;
int k;
while (cin >> s >> k && s[0] != '.')
solve(s, k);
}