超级素数幂(java) import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); long n=in.nextLong(); func(n); } public static void func(long n){ long p=(long)(Math.sqrt(n)+1); long q=2; for(;p>=2;p--){ long tmp=myPow(p,q); long flag=tmp-n; if(flag==0){ if(!isPrime((int)p)) continue; System.out.println(p+" "+q); return ; }else if(flag<0){ q++; p=(long)(Math.pow(n,1.0/q)+1); } //if(!isPrime(p)) continue; //isprime //long tmp=n; /*if((q=isOK(p,tmp))>0){ System.out.println(p+" "+q); return ; }*/ } System.out.println("No"); } public static boolean isPrime(int n){ if(n<=1) return false; for(int i=2;i*i<=n;i++){ if(n%i==0) return false; } return true; } public static long myPow(long p,long q){ return q == 0 ? 1 : myPow(p, q-1) * p; } /*public static long isOK(long p, long n){ if(n==1) return 0; if(n%p==0){ return isOK(p,n/p)+1; } return -1; }*/ }