intSolution::isPower(int A){ if(A == 1) returntrue; vector<int> factor; for(int i = 2; i <= sqrt(A); i++) { if(A % i) continue; int now = 0; while(A % i == 0) { A /= i; now += 1; } factor.push_back(now); } if(A != 1) returnfalse; int g = factor[0]; for(int i = 1; i < factor.size(); i++) g = __gcd(factor[i], g); return g > 1; }