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: Wrong Answer)

#include <stdio.h>

void make_list(int *list);
void sort_list(int *list);
void search(int *list, int X);

int main(void)
{
	int list[50];
	int X;
	
	scanf("%d", &X);
	if (X < 4){
		printf("1\n");
		return (0);
	}
	
	make_list(list);
	sort_list(list);
	search(list, X);
	
	return (0);
}

void make_list(int *list)
{
	int i = 0;
	int n = 2;
	int data = 4;
	
	while (n < 32){
		while (data < 1000){
			list[i] = data;
			data *= n;
			i++;
		}
		n++;
		data = n * n;
	}

}
	
void sort_list(int *list)
{
	int i;
	int D = 0;
	int tmp;
	while (D == 0){
		D = 1;
		i = 0;
		while (i < 49){
			if (list[i] < list[i + 1]){
				tmp = list[i];
				list[i] = list[i + 1];
				list[i + 1] = tmp;
				D = 0;
			}
			i++;
		}
	}
	
}

void search(int *list, int X)
{
	int i;
	
	for (i = 0; i < 50; i++){
		 if (list[i] <= X){
		 	printf("%d\n", list[i]);
			break;
		 }
	}
	
}