/ 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 ≥1099ms ≥568.0 KiB
#4 Time Exceeded ≥1099ms ≥568.0 KiB

Code

#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
const char nl = '\n', sp = ' ';

void solve() {
    int n;
    cin >> n;
    int m = n;
    ll ans = 0;
    for (int l = 1, r; l <= m; l = r + 1) {
        r = m / (m / l);
        ans += 1ll * (r - l + 1) * (m / l);
    }
    ans -= n;
    cout << ans << nl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef LOCAL
    freopen("../in.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

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-26 19:54:07
Judged At
2025-07-26 19:54:07
Judged By
Score
5
Total Time
≥1099ms
Peak Memory
≥568.0 KiB