Comments

Spoiler

now is your comment:)

failed test-case: 1 20 2

your output: 2 4 3 10 5 6 7 8 9 20 11 12 13 14 15 16 17 18 19 1

correct output: 2 4 3 20 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1

another opportunity to feel dumb

0

all the best

another opportunity to feel dumb

+20

we aren't on web3 yet

The same happens to me. The inbuilt sqrt give some precision error for long integers in different systems. You can either use sqrtl (made especially for long long) or find it simply using binary search.

The following code will have different results on codeforces vs my local machine.

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll bs_sqrt(ll x) {
    ll left = 0, right = 2000000123;
    while (right > left) {
        ll mid = (left + right) / 2;
        if (mid * mid > x)
            right = mid;
        else
            left = mid + 1;
    }
    return left - 1;
}

int main() {
    ll l, r;
    cin >> l >> r;
    ll sql_1 = sqrt(l), sqr_1 = sqrt(r);
    ll sql_2 = sqrtl(l), sqr_2 = sqrtl(r);
    ll sql_3 = bs_sqrt(l), sqr_3 = bs_sqrt(r);
    cout << sql_1 << " " << sqr_1 << '\n';
    cout << sql_2 << " " << sqr_2 << '\n';
    cout << sql_3 << " " << sqr_3 << '\n';
    return 0;
}

you stressed enough today

another day to be sad

*liked

well-balanced contest. thank you so much. hated it

Q. how many weak pretests do you want?? A. YESSS!!!

damn how is this possible??

super fast editorial.. great contest.

good resource

noob

would see D

as a #008000 rated, I enjoyed solving C

you never know what happens to a newbie when they read today's C :(

Hey, stop it. Get some help.

because its not there

On huangziruiCodeforces Round #796, 4 years ago
0

guys codechef down again??

same issue belgua

Same

why so many negative upvotes ../