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 C (GCC 5.4.1) (judge verdict: Accepted)

#include <stdio.h>

int main(void) {
    int a;
	scanf("%d", &a);
	int temp=1;
	int b, c,d;
	int max_1=1, max_2=1;
	int mmm=1, end=1;
	for(b=1; b<=100; b++) {
		max_1=1;
		temp=1;
		for (c=2; c<=100; c++) {
			max_1=1;
	    	temp =1;
			d=c;
	    	while (d) {
	    		temp *=b;
		    	d--;
		
	    	}
			if(temp==a) {max_1=temp; break;}
			else if (temp>a) {max_1= temp/b; break; }
		}
		if (max_1==a && max_1!=b) {max_2=max_1; break;}
		else if (max_2<max_1 && max_1!=b) max_2 =max_1;
		
	}   
	printf("%d", max_2);
}