Accepted
Code
#include <bits/stdc++.h>
using namespace std;
long long say(long long n)
{
long long sum=0;
long long k=sqrt(n);
for (long long i=1;i<=k;i++) sum+=floor(n / i);
sum*=2;
sum-=pow(k, 2);
return sum;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--)
{
long long n;
cin>>n;
long long T=say(n)-n;
cout<<T<<"\n";
}
// 19877697634
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:38:57
- Judged At
- 2025-07-14 17:38:57
- Judged By
- Score
- 100
- Total Time
- 351ms
- Peak Memory
- 764.0 KiB