-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquaresandCubes.cpp
More file actions
56 lines (53 loc) · 1.02 KB
/
Copy pathSquaresandCubes.cpp
File metadata and controls
56 lines (53 loc) · 1.02 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<bits/stdc++.h>
using namespace std;
#define fer(i,a,b) for(re i = a; i<b; ++i)
#define re register int
#define pb push_back
#define ll long long
#define mod 1000000007
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pi;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int tc;
cin>>tc;
while(tc--)
{
ll int n ;
cin>>n;
// ll int res = (ll int)sqrt(n) + (ll int)cbrt(n)-(ll int)(sqrt(cbrt(n)));
int c1=0,c2=0,c3=0;
for(int i=1;i*i<=n;i++){
c1++;
}
for(int i=1;i*i*i<=n;i++){
c2++;
}
for(int i=1;i*i*i*i*i*i<=n;i++){
c3++;
}
cout <<c1+c2-c3<<"\n";
}
return 0;
}
//Exceed the time complexity
// for(int i=1;i<=n;i++){
// if(sqrt(i)==int(sqrt(i)) || cbrt(i)==int(cbrt(i))){
// count++;
// }
// }
// int c1=0;
// for(int i=1;i*i<=n;i++){
// c1++;
// }
// for(int i=1;i*i*i<=n;i++){
// c1++;
// }