solved sherlock and squares

Signed-off-by: ayham <altffour@protonmail.com>
This commit is contained in:
ayham 2021-05-15 14:10:20 +03:00
parent 44bee6e8f3
commit ab530893ec
No known key found for this signature in database
GPG Key ID: 81D38F7122AFCC94
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#include <bits/stdc++.h>
using namespace std;
bool is_sqr(long long number) {
if (number >= 0) {
long long sr = sqrt(number);
return (sr * sr == number);
}
return false;
}
int main() {
int q;
long long a, b;
cin >> q;
while (q--) {
cin >> a >> b;
long long counter = 0;
// long long i = ceil(sqrt(a));
// while (true) {
// if (pow(i, 2) <= b && pow(i, 2) >= a)
// counter++;
// else break;
// i++;
// }
if (is_sqr(b)) counter++;
counter += abs(ceil(sqrt(a))-ceil(sqrt(b)));
cout << counter << endl;
}
return 0;
}