/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 2ms 536.0 KiB
#3 Time Exceeded ≥1099ms ≥572.0 KiB
#4 Time Exceeded ≥1099ms ≥564.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long
// #define int long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // for (int i = 1; i < N; i++)
    // {
    //     for (int j = i; j < N; j += i)
    //     {
    //         di[j]++;
    //     }
    // }
    // for (int i = 1; i < N; i++)
    //     di[i]--;
    // for (int i = 1; i < N; i++)
    //     di[i] += di[i - 1];
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        // cout << di[n] << "\n";
        ll ans = 0;
        for (int i = 1, j; i <= n; i = j + 1)
        {
            int q = n / i;
            j = n / q;
            ans += 1ll * (j - i + 1) * q;
        }
        cout << ans - n << '\n';
    }
}

Information

Submit By
Type
Submission
Problem
P1207 D2. GCD equal Absolute Value (Hard Version)
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 17:12:21
Judged At
2025-07-14 17:12:21
Judged By
Score
5
Total Time
≥1099ms
Peak Memory
≥572.0 KiB