-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgorithm-BinarySearch.cpp
More file actions
77 lines (57 loc) · 1.06 KB
/
Algorithm-BinarySearch.cpp
File metadata and controls
77 lines (57 loc) · 1.06 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
/*Feito por João Claudio Soares*/
int binarySearch(vector<long long int> &vet,int b,int es,int di){
if(es > di)
{
return -1;
}else
{
int mei=(es+di)/2;
if(vet[mei]==b)
{
return mei;
}else
{
if(vet[mei] < b)
{
es =mei+1;
}else
{
di = mei-1;
}
}
binarySearch(vet, b, es, di);
}
}
long long int berificaEl(long long int n){
long long int kt =0 , kq = 1, kc = 1, conta=1;
vector<long long int> vet;
for(long long int i = 1; i <= 1000 ; i++)
{
vet.push_back(i*i);
}
for(long long int i = 2; i <= 1000 ; i++)
{
vet.push_back(i*i*i);
}
sort(vet.begin(), vet.end());
vector< long long int>::iterator it = lower_bound(vet.begin(), vet.end(),n);
int a = binarySearch(vet,*it , 0, (vet.size())-1);
return a;
}
main()
{
ios::sync_with_stdio(false);
cin.tie(0);
long long int t, n;
cin >>t;
while(t--)
{
cin >>n;
cout <<berificaEl(n)<<"\n";
}
return 0;
}