-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSherlock&Squares.cpp
More file actions
43 lines (43 loc) · 862 Bytes
/
Sherlock&Squares.cpp
File metadata and controls
43 lines (43 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int t;
long a,b,num;
int c=0;
int f=0;
cin>>t;
while(t--)
{
cin>>a>>b;
for(long i=a;i<=b;i++)
{
double k1=pow(i,0.5);
long k2=(long)k1;
if(k1==k2)
{
c++;
while(1)
{
k2++;
num=pow(k2,2);
if(num<=b)
c++;
else
{
f--;
break;
}
}
if(f<0)
break;
}
if(f<0)
break;
}
cout<<c<<endl;
c=0;
f=0;
}
}