/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 2ms 348.0 KiB
#3 Accepted 197ms 576.0 KiB
#4 Accepted 197ms 552.0 KiB
#5 Accepted 200ms 568.0 KiB
#6 Accepted 64ms 532.0 KiB
#7 Accepted 199ms 568.0 KiB

Code

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);

    int t;
    cin >> t;

    while (t--)
    {
        int n;
        cin >> n;
        
        long long res = 0;
        
        for (int ptr = 1; ptr * ptr <= n; ptr++)
        {
            res += n / ptr;
            res += 1LL * ptr * (n / ptr - n / (ptr + 1) - (n / ptr == ptr));
        }
        
        cout << res - n << "\n";
    }

    return 0;
}

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 16:44:57
Judged At
2025-07-14 16:44:57
Judged By
Score
100
Total Time
200ms
Peak Memory
576.0 KiB