-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpower_strings.cpp
More file actions
63 lines (54 loc) · 1.42 KB
/
power_strings.cpp
File metadata and controls
63 lines (54 loc) · 1.42 KB
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
59
60
61
62
63
/*
Made by: Romeu I. L. Pires
for "Special topics in programming" course
in UFRJ (Universidade Federal do Rio de Janeiro),
on 2019.1 semester
- Problem PDF:
https://uva.onlinejudge.org/external/102/10298.pdf
*/
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
vector<int>& preffixVector( const string& str ){
vector<int> ret( str.size() );
return ret;
}
bool hasSubstr( const string& text , const string& pattern ){
return true;
}
int powerString( const string& msg ){
for( int i = msg.size() ; i > 1 ; ){
if( msg.size() % i != 0 ){
i--;
}else{
int substr_size = msg.size()/i;
string substr = msg.substr(0, substr_size );
bool ok = true;
for( int j = substr_size ; j < msg.size() ; j += substr_size )
if( substr != msg.substr(j,substr_size) )
{
ok = false; break;
}
if(ok) return i;
i = msg.size() / ( substr_size + 1 );
}
}
return 1;
}
int main(){
#ifndef ONLINE_JUDGE
ifstream cin("entrada.txt");
ofstream cout("saida.txt");
#endif
// ==========
string line;
while( true ){
getline( cin , line );
if( line == "." ) break;
else cout << powerString(line) << endl;
}
return 0;
}