Time Exceeded
Code
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
void solve() {
int n; cin >> n;
long long last = 0, val = 0, ans = 0;
for (int i = 1; i <= n; i = n/val + 1) {
ans += val*(i - last);
last = i, val = n/i;
}
ans += (n+1) >> 1;
cout << ans - n << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t; cin >> t;
while (t--)
solve();
}
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:28:57
- Judged At
- 2025-07-14 17:28:57
- Judged By
- Score
- 5
- Total Time
- ≥1100ms
- Peak Memory
- ≥568.0 KiB