int ans = 0; auto solve = [&](ll t) { auto cal = [&](ll b) { ll a = b + t; vector<ll> powa(k), powb(k); powa[0] = powb[0] = 1; for (int i = 1; i < k; ++i) { if (1.0 * powa[i - 1] * a > inf) return inf; powa[i] = powa[i - 1] * a; if (1.0 * powb[i - 1] * b > inf) return inf; powb[i] = powb[i - 1] * b; } ll sum = 0; for (int i = 0; i < k; ++i) { if (1.0 + sum + powa[i] * powb[k - 1 - i] > inf) return inf; sum += powa[i] * powb[k - 1 - i]; } if (1.0 * sum * (a - b) > inf) return inf; sum *= a - b; return sum; }; ll l = 1, r = 1e9; while (l < r) { ll mid = l + r >> 1; if (cal(mid) >= n) r = mid; else l = mid + 1; } ans += cal(l) == n; };
for (ll i = 1; i * i <= min(mx, n); ++i) { if (n % i) continue; solve(i); if (i != n / i) solve(n / i); }
cout << ans << "\n"; }
return0; }
/********************************************************************** Problem: 1245 User: KobicGend Language: C++ Result: AC Time:259 ms Memory:2380 kb **********************************************************************/