# Getting TLE on submission but case passes on custom input

#1

I have basically found the prime factorisation of the number and found out if all the powers are divisible by some common integer. this common integer is less than equal to the max power of a prime in its factorisation

vector v1;
bool isPrime(long long n){
for(long long i=0; i<v1.size(); i++){
if(n%v1[i]==0) return false;}

return true;
}

int Solution::isPower(int A) {

``````int n = A;
v1.push_back(2);
for(long long p = 3; p<=100001; p+=2){
if(isPrime(p))
v1.push_back(p);
}
unordered_map <long long, long long> y ;
int mini = INT_MAX;
for(long long i = 0; i<v1.size(); i++){
while(n%v1[i]==0){
y[v1[i]]++;
n=n/v1[i];
}
if(y[v1[i]]<mini && y[v1[i]]!=0){
mini = y[v1[i]];
}
}
if(n>2){
y[n] = 1;
}
vector<pair<long long, long long>>v;
for(auto i : y){
if(i.second!=0){
v.push_back({i.first, i.second});
}
}
for(int j = 2; j<=mini; j++){
int flag = 0;
for(int i = 0; i<v.size(); i++){
if(v[i].second%j!=0){
flag = 1;
break;
}
}
if(flag == 0)
return 1;
}
return 0;
``````

}