Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include "bits/stdc++.h"
- using namespace std;
- #define all(a) a.begin(), a.end()
- #define int long long
- const int inf = LLONG_MAX;
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- //a[i] / x = (1 + x)^(i - 2)
- int m; cin >> m;
- int res = 2;
- auto try_solve = [&](int x) {
- int d = m / x;
- int y = 1;
- int cnt = 2;
- while (1) {
- if (d % (1 + x) == 0) {
- d /= (1 + x);
- cnt++;
- }
- else {
- break;
- }
- }
- return cnt;
- };
- for (int i = 2; i * i * i <= m; i++) {
- if (m % i == 0) {
- res = max({ res, try_solve(m / i), try_solve(i) });
- }
- }
- int tl = 0, tr = (int)sqrt(m) + 1;
- while (tr - tl > 1) {
- int tm = (tr + tl) / 2;
- if (tm * (tm + 1) >= m) {
- tr = tm;
- }
- else {
- tl = tm;
- }
- }
- if (tr * (tr + 1) == m) {
- res = max(res, 3ll);
- }
- cout << res << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement