-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdancineTheCheekyCheeky_UVA11452.cpp
58 lines (49 loc) · 1.17 KB
/
dancineTheCheekyCheeky_UVA11452.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <string>
#include <vector>
using namespace std;
ifstream fin("dancineTheCheekyCheeky_UVA11452.in");
ofstream fout("dancineTheCheekyCheeky_UVA11452.out");
int main()
{
int T; fin >> T;
for (int t = 1; t <= T; ++t)
{
string a, loop; fin >> a;
int size = a.size(), miss, start;
if (size % 3 == 0)
{
start = size / 3;
}
else
{
start = size / 3 + 1;
}
for (int s = start; s <= size / 2; ++s)
{
string temp1 = a.substr(0, s), temp2 = a.substr(s, s);
if (temp1 == temp2)
{
miss = size - s * 2;
loop = temp1;
break;
}
}
int _count = 8, sizeL = loop.size();
for (int i = miss; _count > 0; ++i)
{
i %= sizeL;
fout << loop[i];
--_count;
}
fout << "...\n";
}
return 0;
}