/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 4ms 572.0 KiB
#3 Time Exceeded ≥1099ms ≥568.0 KiB
#4 Time Exceeded ≥1000ms ≥572.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'
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int div(int n)
{
    int ans = 0;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ans++;
            if (i * i != n)
                ans++;
        }
    }
    return ans;
}
const int N = 1e6 + 5;
int di[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";
        int ans = 0;
        for (int i = 1, j; i <= n; i = j + 1)
        {
            int q = n / i;
            j = n / q;
            ans += (j - i + 1) * q;
        }
        cout << ans - n << endl;
    }
}

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:11:18
Judged At
2025-07-14 17:11:18
Judged By
Score
5
Total Time
≥1099ms
Peak Memory
≥572.0 KiB