Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int n;
- scanf("%d", &n);
- string s = "";
- cin >> s;
- vector<int> component;
- double t = sqrt(n);
- for(int i = 1; i <= t; ++i){
- if(n % i == 0){
- component.push_back(i);
- component.push_back(n / i);
- }
- }
- sort(component.begin(), component.end());
- for(auto x : component){
- string news = s;
- news += news.substr(0, x);
- news = news.substr(x, n + x);
- if(news == s){
- cout << x;
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement