/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Time Exceeded ≥1099ms ≥820.0 KiB
#3 Time Exceeded ≥1100ms ≥788.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
P1206 D1. GCD equal Absolute Value (Easy Version)
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-26 19:54:51
Judged At
2025-07-26 19:54:51
Judged By
Score
0
Total Time
≥1100ms
Peak Memory
≥820.0 KiB