Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- #define vec vector
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- void cvb(vector <bool> v){
- for (bool x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvs(vector <string> v){
- for (auto a: v){
- cout<<a<<"\n";
- }
- }
- void cvp(vector <pii> a){
- for (auto p: a){
- cout<<p.first<<' '<<p.second<<"\n";
- }
- cout<<"\n";
- }
- ll mod = 1e9+7, p = 101;
- bool sh=0;
- ll f(char x){
- ll d ;
- d = x - 'A' + 1;
- return d;
- }
- /*
- zabcd
- abcdz
- */
- int main()
- {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- string s; cin>>s;
- int n = s.size();
- vector <ll> powp(2*n, 1);
- for (int i = 1; i < 2*n; ++i){
- powp[i] = powp[i-1] * p % mod;
- }
- vector <ll> pf(n);
- pf[0] = f(s[0]);
- for (int i = 1; i < n; ++i){
- pf[i] = pf[i - 1] + powp[i] * f(s[i]);
- pf[i] %= mod;
- }
- vector <int> div;
- for (int i = 1; i <= n; ++i){
- if (n % i == 0){
- div.push_back(i);
- }
- }
- reverse(div.begin(), div.end());
- //0 3 6 9 12
- //0 2 4
- for (int d: div){
- bool ok = 1;
- for (int i = 1; i < n / d; ++i){
- int a = i * d, b = i * d + d - 1;
- if ((pf[b] - pf[a-1] + mod) % mod != pf[d - 1] * powp[a] % mod){
- ok=0;
- break;
- }
- }
- if (ok){
- cout<<d;
- exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement