Skip to content
Snippets Groups Projects
Commit c1597df5 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Add ICPC_SA17/J.cpp

parent 4f887bee
No related branches found
No related tags found
No related merge requests found
#include <bits/stdc++.h>
#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define ende '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
string s; cin >> s;
int n = s.size();
int r = 0;
for (int i = 0; i < n; ++i)
r += (s[i] == 'R');
if (r == n)
return cout << n - 1 << ende, 0;
vector<int> divs;
for (int i = 2; i*i <= n; ++i)
if (n % i == 0) {
divs.pb(i);
if (i != n / i)
divs.pb(n / i);
}
vector<int> nums(n, 0);
for (int i = 2; i < n; ++i)
nums[__gcd(i, n)]++;
int ans = 0;
for (auto i : divs) {
bool poss = false;
for (int j = 0; j < i; ++j) {
bool onlyr = true;
for (int k = j; k < n; k += i)
onlyr &= (s[k] == 'R');
if (onlyr) {
poss = true;
break;
}
}
if (poss)
ans += nums[i];
}
cout << ans << ende;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment