Problem:
Score : 200 points

Problem Statement

You are given a positive integer X.
Find the largest perfect power that is at most X.
Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Constraints

1 ≤ X ≤ 1000

X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

Print the largest perfect power that is at most X.

Sample Input 1

10

Sample Output 1

9

There are four perfect powers that are at most 10: 1, 4, 8 and 9.
We should print the largest among them, 9.

Sample Input 2

1

Sample Output 2

1

Sample Input 3

999

Sample Output 3

961

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  // String nyuA=sc.nextLine();
//  String nyuB=sc.nextLine(); 
 

   //String[] s=sc.nextLine().split(" ");
 //    String[] t=sc.nextLine().split("");

   String nyuA=sc.nextLine();


//int N=Integer.parseInt(nyuA);
//int A=Integer.parseInt(s[0]);
//int B=Integer.parseInt(s[1]);
//int C=Integer.parseInt(s[2]);

int X=Integer.parseInt(nyuA);
TreeSet<Long> set=new TreeSet<>();
for(int i=1;i<=X;i++){
long temp=i;
//System.out.println(2+"--");
for(int j=1;j<=X;j++){
temp*=i;

set.add(temp);
//System.out.println(temp+"-0-0-0");
if(temp>X)break;

}
}
ArrayList<Long> sets=new ArrayList<>(set);
long count=0;
for(Long t:sets){
//System.out.println(t);
if(X<=t)break;
count++;
}
try{
System.out.println(sets.get((int)count-1));
}catch(Exception e){}


}

}