1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21<snippet>
<content><![CDATA[
// works for at least up to (2**31 — 1)**2
long long sqrt_floor (long long x) {
long long ans = 0;
for (ll k = 1LL << 30; k != 0; k /= 2) {
if ((ans + k) * (ans + k) <= x) {
ans += k;
}
}
return ans;
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>sqrt floor</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
</snippet>