/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 135ms 15.824 MiB
#2 Accepted 149ms 16.176 MiB
#3 Accepted 152ms 16.285 MiB
#4 Accepted 153ms 16.098 MiB
#5 Accepted 169ms 16.312 MiB
#6 Accepted 150ms 16.27 MiB

Code

#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif

using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';

const int N = 1e6 + 5;
vector<int> spf(N), ans(N);
int last = 1;
int nod(int x) {
    int ret = 1;
    while (spf[x] > 1) {
        int now = spf[x], cnt = 0;
        while (spf[x] == now) x /= spf[x], cnt++;
        ret *= (cnt + 1);
    }
    return ret;
}

void shelby() {
    int n;
    cin >> n;
    cout << ans[n] << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    iota(spf.begin(), spf.end(), 0);
    for (int i = 2; i < N; ++i) {
        if (spf[i] == i) {
            for (int j = i * i; j < N; j += i) if (spf[j] == j) spf[j] = i;
        }
    }
    ans[1] = 1;
    for (int i = 2; i < N; ++i) {
        int a = (i + 1) / 2, b = i + (i % 2 == 0), d = nod(a) * nod(b);
        if (d > last) {
            ans[i] = d;
            last = d;
        }
        else ans[i] = ans[i - 1];
    }
    int t = 1;
    cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case " << _ << ": ";
        shelby();
    }
}

Information

Submit By
Type
Submission
Problem
P1180 Maximum Divisor
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-11 07:16:15
Judged At
2025-04-11 07:16:15
Judged By
Score
100
Total Time
169ms
Peak Memory
16.312 MiB