Created
September 18, 2016 19:01
-
-
Save blogdarkspot/89c9b0792b4b2641783653acf4e5ab38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <queue> | |
#include <string> | |
using namespace std; | |
int main(int argc, char **argv) { | |
string _text; | |
int _size; | |
bool _finish, _match; | |
while (getline(cin, _text)) { | |
_size = 0; | |
_finish = false; | |
while(!_finish) { | |
_size ++; | |
if (_text.size() < _size) { | |
_finish = true; | |
continue; | |
} | |
if (_text.size() % _size) | |
continue; | |
string _subText = _text.substr(0, _size); | |
_match = true; | |
for(int position = 0; position < _text.size(); position += _size) { | |
if ( _text.compare(position, _size, _subText)) { | |
_match = false; | |
break; | |
} | |
} | |
if(_match) _finish = true; | |
} | |
cout << _text.size() / _size << " * " << _text.substr(0, _size) << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment