Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
void solve(){
long long n;
cin >> n;
long long mid = sqrt(1e9);
long long ans = 0;
for(int i = 1 ; i <= min(mid,n) ; i++){
ans += n / i - 1;
}
if(n <= mid){
cout << ans << endl;
return;
}
int j = mid + 1;
while(n / mid == n / j){
ans += n / j - 1;
j++;
}
for(int i = (n / j) ; i >= 1 ; i--){
ans += i * max(0ll,n / i - max(mid+1,n / (i + 1)));
}
cout << ans - (n - j + 1) << endl;
}
int main()
{
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1207 D2. GCD equal Absolute Value (Hard Version)
- Language
- C++11 (G++ 13.2.0)
- Submit At
- 2025-07-14 19:15:24
- Judged At
- 2025-07-14 19:15:24
- Judged By
- Score
- 5
- Total Time
- 896ms
- Peak Memory
- 548.0 KiB