Please help, I am not able to find the issues in my code
Here is problem link - Powered Parameters Practice Coding Problem - CodeChef
Here is my code.
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define ll long long
#define lli long long int
#define yesno(x) cout << ((x) ? "yes" : "no")
#define sort(arr) sort(arr.begin(),arr.end())
#define reverse(arr) reverse(arr.begin(),arr.end())
#define inputArr(n) for(int i = 0; i < n; i++) cin >> arr[i]
#define vi vector<int>
using namespace std;
int binSearch(vector<int>& root, int el) {
int i = 0, j = root.size()-1;
int n = root.size();
int ans = n;
while(i <= j) {
int mid = (i+j)/2;
if(el <= root[mid]) {
ans = mid;
j = mid-1;
}
else i = mid + 1;
}
return n-ans;
}
void solve() {
int n;
cin >> n;
vi arr(n);
inputArr(n);
vector<int> root(n);
for(int i = 0; i < n; i++) {
int power = pow(arr[i], 1.0/(i+1));
root[i] = power;
}
sort(root);
lli cnt = 0;
for(auto i: arr) {
cnt += binSearch(root, i);
}
cout << cnt;
}
int main(){
int t;
cin >> t;
while(t--) {
solve();
cout << endl;
}
return 0;
}