/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 568ms 89.832 MiB
#2 Accepted 577ms 90.203 MiB
#3 Accepted 577ms 90.215 MiB
#4 Accepted 574ms 90.387 MiB
#5 Accepted 572ms 90.203 MiB
#6 Accepted 570ms 90.336 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 9;
bitset<N> f;
int spf[N], res[N];
vector<int> fact[N];
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n = N - 9;
    vector<int> primes;
    for (int i = 1; i < N; i++)
        spf[i] = i;
    for (int i = 2; i < N; i++)
    {
        for (int j = i; j < N; j += i)
        {
            spf[j] = min(spf[j], i);
        }
    }
    f[1] = true;
    for (int i = 2; i * i <= n; i++)
    {
        if (!f[i])
        {
            for (int j = i * i; j <= n; j += i)
            {
                f[j] = true;
            }
        }
    }
    for (int i = 2; i <= n; i++)
    {
        if (!f[i])
        {
            primes.push_back(i);
        }
    }
    for (int i = 1; i < N - 1; i++)
    {
        int x = i;
        while (x > 1)
        {
            int p = spf[x];
            fact[i].push_back(p);
            x /= p;
        }
    }
    int mx = 0;
    for (int i = 1; i < N - 1; i++)
    {
        map<int, int> cnt;
        for (auto x : fact[i])
            cnt[x]++;
        for (auto x : fact[i + 1])
            cnt[x]++;
        cnt[2]--;
        int ans = 1;
        for (auto x : cnt)
            ans *= (x.second + 1);
        res[i] = max(res[i - 1], ans);
    }
    int t;
    cin >> t;
    while (t--)
    {
        int m;
        cin >> m;
        cout << res[m] << '\n';
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1180 Maximum Divisor
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-06 18:30:10
Judged At
2025-04-06 18:30:10
Judged By
Score
100
Total Time
577ms
Peak Memory
90.387 MiB