Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
- //#include <ext/pb_ds/assoc_container.hpp>
- //using namespace __gnu_pbds;
- //typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
- std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
- const int INF = 1e18 + 7;
- const double EPS = 1e-10;
- const int MOD = 1e9 + 7;
- const int MAXN = 3e6 + 100;
- int n;
- vector<int> a;
- int get(int k) {
- int g = -1;
- for (int i = 0; i < k; ++i) {
- int cur = -1;
- for (int j = i; j + k < n; j += k) {
- if (cur == -1) {
- cur = abs(a[j] - a[j + k]);
- } else {
- cur = __gcd(cur, abs(a[j] - a[j + k]));
- }
- }
- if (g == -1) {
- g = cur;
- } else {
- g = __gcd(g, cur);
- }
- }
- if (g == 1) return 0;
- int res = 1;
- for (int i = 2; i * i <= g; ++i) {
- int cnt = 0;
- while (g % i == 0) {
- ++cnt;
- g /= i;
- }
- res *= cnt + 1;
- }
- if (n != 1) {
- res *= 2;
- }
- return res - 1;
- }
- inline void solve() {
- cin >> n;
- a.resize(n);
- for (int i = 0; i < n; ++i) {
- cin >> a[i];
- }
- int ans = 0;
- for (int i = 2; i <= ceil(sqrt(n)); ++i) {
- if (n % i == 0) {
- ans += get(i);
- if (i != n / i) {
- ans += get(n / i);
- }
- }
- }
- cout << ans + 1 << '\n';
- }
- int32_t main() {
- IOS;
- clock_t tStart = clock();
- int tt = 1;
- cin >> tt;
- while (tt --> 0) {
- solve();
- }
- // cerr << "Runtime is:" << (long double) (clock() - tStart) / CLOCKS_PER_SEC << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment