Time Exceeded
Code
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
cin.tie(0) -> sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int x = n, d = 1;
int64_t ans = 0;
while (d <= n) {
int nxt = n / (n / d);
ans += (n / d) * 1LL * (nxt - d + 1);
d = nxt + 1;
}
cout << ans - 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 17:53:13
- Judged At
- 2025-07-14 17:53:13
- Judged By
- Score
- 5
- Total Time
- ≥1099ms
- Peak Memory
- ≥572.0 KiB