/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'long long int sum_floor(long long int)':
foo.cc:8:12: error: 'sqrtl' was not declared in this scope; did you mean 'strtol'?
    8 |     ll s = sqrtl(N);
      |            ^~~~~
      |            strtol

Code

#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

ll sum_floor(ll N) {
    ll s = sqrtl(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:21
Judged At
2025-07-14 17:28:21
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes