Time Exceeded
Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
int sum = 0;
for (int l = 1, r; l <= n; l = r + 1)
{
int q = n / l;
r = n / q;
sum += q * (r - l + 1);
}
cout << sum - 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:28:20
- Judged At
- 2025-07-14 17:28:20
- Judged By
- Score
- 5
- Total Time
- ≥1100ms
- Peak Memory
- ≥764.0 KiB