Time Exceeded
Code
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
i64 ans = 0;
for (i64 i = 1, r; i <= n; i = r + 1)
{
i64 q = n / i;
r = n / q;
ans += q * (r - i + 1);
}
ans -= n;
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 17:31:28
- Judged At
- 2025-07-14 17:31:28
- Judged By
- Score
- 5
- Total Time
- ≥1099ms
- Peak Memory
- ≥564.0 KiB