My issue
Can anyone explain me how can I approach the problem. I think bit manipulation will be used here to reduce time complexity.
My code
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int main() {
// your code goes here
long long int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int> a;
for(int i=0;i<n;i++){
int a1;
cin>>a1;
a.push_back(a1);
}
int count=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(a[i]>a[j]){
continue;
}
if(pow(a[i],j+1)<=a[j]){
count++;
}
}
}
cout<<count<<endl;
}
return 0;
}
Problem Link: Powered Parameters Practice Coding Problem - CodeChef