The meaning of problems: Input n, minimization of all prime factors of powers. n odd Titanic.
Ideas: First of all n for n After about five times the square root of the quality factor apart, and if it is not divisible, a factor of at most 4, where it has a power of greater than 1 p1 ^ 4, p1 ^ 3, p1 ^ 2 other cases there must be a power of 1.
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> using namespace std; int a[1000010]; int b[1000010]; int main() { int t,k=0; for(int i=2;i<=1000000;i++) { if(b[i]==0) { a[k++]=i; for(int j=i+i;j<=1000000;j+=i) { b[j]=1; } } } while(~scanf("%d",&t)) { while(t--) { long long n; scanf("%lld",&n); int y=powl(n,1/5.0); // printf("y:%d\n",y); int m=99999; for(int i=0;i<k;i++) { // printf("%d----\n",a[i]); if(a[i]>y) break; if(n%a[i]==0) { int r=0; while(1) { if(n%a[i]) { break; } n/=a[i]; r++; } m=min(m,r); } } //printf("%lld\n",n); if(n!=1){ long long y4=powl(n,1/4.0); long long y3=powl(n,1/3.0); long long y2=powl(n,1/2.0); if(y4*y4*y4*y4==n) { m=min(m,4); } else if(y3*y3*y3==n) { m=min(m,3); } else if(y2*y2==n) { m=min(m,2); } else { m=min(m,1); } } printf("%d\n",m); } } }
The official solution to a problem writing the code or wa. . .