Help me in solving POWPM problem

My issue

For this problem, my code works well for all the testcases but except the last one. I could not find what would be the edge case or where my code fails, Can anyone figure it out?

My code

import bisect 

for MIGHTY in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    x = sorted(l)
    ans = 0
    for i in range(n) :
        now = (pow(l[i], 1/(i+1)))
        y = bisect.bisect_right(x, now)
        ans += y
    
    print(int(ans))

Problem Link: Powered Parameters Practice Coding Problem - CodeChef

@mighty_my3
taking jth root can fail at certain precision level .
plzz refer my c++ code for better understanding of the logic

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    long long int n;
	    cin>>n;
	    long long int a[n],ans=0;
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	    }
	    for(int i=0;i<n;i++)
	    {
	        if(a[i]==1)
	        ans+=n;
	        else
	        {
	            long long int val=1;
	            for(int j=0;j<min(32LL,n);j++)
	            {
	                val*=a[i];
	                if(val>1e9)
	                break;
	                if(val<=a[j])
	                ans++;
	            }
	        }
	    }
	    cout<<ans<<endl;
	}
	return 0;
}
1 Like

Thank you !