/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 70ms 16.242 MiB
#2 Accepted 91ms 16.531 MiB
#3 Accepted 110ms 16.617 MiB
#4 Accepted 121ms 16.383 MiB
#5 Accepted 83ms 16.656 MiB

Code

#pragma GCC optimize("O3", "inline")
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;
#define pb push_back
#define ub upper_bound
#define INF 1e18 + 100

const int maxn = 1e6;
int spf[maxn + 1];
int divsc[maxn + 1];
ll pa[maxn + 2];

void prec(){
    fill(spf, spf + maxn, 0);
    vector<int> primes;
    spf[1] = 1;
    for(int i = 2; i <= maxn; i++){
        if(!spf[i]){
            spf[i] = i;
            primes.pb(i);
        }
        for(int p: primes){
            if(i * p > maxn) break;
            spf[i * p] = p;
            if(i % p == 0) break;
        }
    }
    divsc[1] = 1;
    for(int i = 2; i <= maxn; i++){
        ll me = 1;
        int x = i;
        while(x > 1){
            int fac = spf[x];
            int cnt = 0;
            while(spf[x] == fac){
                cnt++;
                x /= fac;
            }
            me = me * (cnt + 1);
        }
        divsc[i] = me;
    }
    pa[1] = 0;
    for(int i = 1; i <= maxn; i++){
        pa[i + 1] = pa[i] + divsc[i] - 1;
    }
}

ll solve()
{
    int n;
    cin >> n;
    return pa[n + 1];
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    prec();
    while(t--)
    {
        ll x = solve();
        cout << x << "\n";
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1206 D1. GCD equal Absolute Value (Easy Version)
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-15 06:00:33
Judged At
2025-07-15 06:00:33
Judged By
Score
100
Total Time
121ms
Peak Memory
16.656 MiB