Time Exceeded
Code
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline ll sum_floor_div(ll N, ll M) {
ll res = 0;
for (ll d = 1, R; d <= M; d = R + 1) {
ll q = N / d;
R = N / q;
if (R > M) R = M;
res += q * (R - d + 1);
}
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while (T--) {
ll N; cin >> N;
if (N == 1) {
cout << "0\n";
continue;
}
ll ans = sum_floor_div(N, N - 1) - (N - 1);
cout << ans << '\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 16:24:18
- Judged At
- 2025-07-14 16:24:18
- Judged By
- Score
- 5
- Total Time
- ≥1099ms
- Peak Memory
- ≥764.0 KiB