/ SeriousOJ /

Record Detail

Time Exceeded


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

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

ll solve()
{
    int n;
    cin >> n;
    ll ans = 0;
    ll i = 1;
    for(; i * i <= n; i++){
        ans = ans + (n / i) - 1;
    }
    while(i <= n){
        ll j = n / (n / i);
        ans = ans + (j - i + 1) * (n / i - 1);
        i = j + 1;
    }
    return ans;
}

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

Information

Submit By
Type
Submission
Problem
P1207 D2. GCD equal Absolute Value (Hard Version)
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-15 06:45:52
Judged At
2025-07-15 06:45:52
Judged By
Score
5
Total Time
≥1100ms
Peak Memory
≥568.0 KiB