Compile Error
foo.cc: In function 'long long int sum_floor(long long int)': foo.cc:8:12: error: 'sqrt' was not declared in this scope 8 | ll s = sqrt(N); | ^~~~
Code
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
ll sum_floor(ll N) {
ll s = sqrt(N);
while ((s + 1) * (s + 1) <= N) ++s;
while (s * s > N) --s;
ll acc = 0;
for (ll i = 1; i <= s; ++i) acc += N / i;
return acc * 2 - s * s;
}
int main() {
// fast io
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin>>T;
for(int t=1;t<=T;t++) {
ll N;
cin>>N;
ll ans = sum_floor(N)-N;
cout << ans << "\n";
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1206 D1. GCD equal Absolute Value (Easy Version)
- Contest
- Educational Round 1
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-07-14 17:28:45
- Judged At
- 2025-07-14 17:28:45
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes