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



Sample input:
10


Sample output:
9

Submission status: Accepted

Solution code:
# coding: utf-8
X = int(input())
ans = 1
for i in range(2, 32):
    for j in range(2, 11):
        n = i ** j
        if n > ans and n <= X:
            ans = n
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
num = []
for i in range(100):
    for j in range(2,10):
        if i**j <= x:
            num.append(i**j)
print(max(num))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

x = int(input())
ans = 1
for a in range(1,x+1):
    for b in range(2,11):
        c = a ** b 
        if c > x:
            break
        else:
            #print(ans,c)
            ans = max(c,ans)
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

ans = 1
for i in range(1,X+1):
  for p in [2, 3, 5, 7]:
    if(i**p <= X):
      ans = max(ans, i**p)
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
for i in range(100):
    if i**2 > X:
        break
    for j in range(10):
        t = i**j
        if t > X:
            break
        elif t > ans:
            ans = t
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
maxval = 0
for i in range(1, x + 1):
	for j in range(2, 30):
		if i ** j <= x:
			maxval = max(maxval, i**j)
print(maxval)

Submission status: Accepted

Solution code:
def main() -> None:
    X = int(input())
    ans = 0
    for i in range(1, X + 1):
        for j in range(2, X + 1):
            if i ** j > X:
                break
            elif ans < i ** j:
                ans = i ** j
    print(ans if X != 1 else 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
import math

def solve(x):
  if x == 1:
    return x

  ans = 1
  for i in range(2, math.ceil(x ** 0.5)+1):
    j = 2
    while(i**j <= x):
      ans = max(ans, i**j)
      j += 1
  return ans

X = int(input())
print(solve(X))

Submission status: Accepted

Solution code:
x=int(input())
m=int(x**0.5)
r=[1]
for i in range(2,x+1):
        c=2
        while i**c<=x:
                r.append(i**c)
                c+=1
ans=sorted(r)[-1]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=[]
if n==1:print(1)
else:
    for i in range(2,33):
        a=i*i
        if a>n:continue
        while 1:
            if a<=n:a*=i
            else:
                ans.append(a//i)
                break
    ans.sort()
    print(ans[-1])

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for i in range(1, 1001):
    for j in range(2, 20):
        if i**j <= x:
            ans = max(ans, i**j)
print(ans)

Submission status: Accepted

Solution code:
import math

beki=[]
beki.append(1)
x=int(input())
for i in range(2,x):
  p=2
  while(i**p<=x):
    beki.append(i**p)
    p+=1
print(max(beki))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc097/tasks/abc097_b
x = int(input())
m = int(x ** 0.5)
r = [1]
for i in range(2, m + 1):
    c = 2
    while x >= i ** c:
        r.append(i ** c)
        c += 1
print(sorted(r)[-1])

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    ans = 1
    b = 2
    while b**2 <= X:
        p = 2
        while b**p <= X:
            ans = max(ans, b**p)
            p += 1
        b += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
X = int(input())
result = []
for i in range(2,10):
  for j in range(1,32):
    if j**i <= X:
      result.append(j**i)

print(max(result))

Submission status: Accepted

Solution code:
X = int(input())
M = 0

if X < 4:
    print(1)
else:
    for i in range(2, round(X **(1/2)) + 1):
        s = 1
        while s * i <= X:
            s = s * i
        M = max(M, s)
    print(M)

Submission status: Accepted

Solution code:
X=int(input())
L=[1]
for i in range(2,X+1):
  j=2
  while i**j<=X:
    L.append(i**j)
    j+=1
print(max(L))

Submission status: Accepted

Solution code:
X = int(input())
List = list()

for x in range(2,33):
    List.append(x)

answer = 0

for x in range(X,0,-1):
    for y in List:
        number = x
        n = 0
        if number % y == 0:
            while number % y == 0:
                number //= y
                n += 1
            if number == 1 and n >= 2:
                answer = x
                break
    if not answer == 0:
        break

if answer == 0:
    answer = 1

print(answer)

Submission status: Accepted

Solution code:
r=range(1,32);x=int(input());print(max(b**p*(b**p<=x)for p in r[1:]for b in r))

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  X = int(input())
  cur = 0
  for i in range(2, 11):
    for j in range(1, X+1):
      if int(j**i) <= X:
        cur = max(cur, int(j**i))
  print(cur)



if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n=int(input())

ans=[]
for i in range(int(1+n**0.5)):
  suu=i+1
  for j in range(int(1+n**0.5)):
    kotae=suu**j
    if(kotae<=n):
      ans.append(kotae)
print(max(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

X = int(input())

s = set()
s.add(1)
for i in range(2, 1001):
    t = i
    while True:
        t *= i
        if t > 1000:
            break
        s.add(t)

while True:
    if X in s:
        print(X)
        break
    else:
        X -= 1

Submission status: Accepted

Solution code:
x=int(input())
m=0
if x==1:
    print(1)
else:  
    for i in range(2,50):
        j=2
        while i**j<=x:
            if m<i**j:
                m=i**j
            j+=1
    print(m)

Submission status: Accepted

Solution code:
import math


def main():
    X = int(input())
    ans = 0
    for b in range(1, int(math.sqrt(X))+1):
        p = 2
        while b**p <= X:
            if b**p > ans:
                ans = b**p
            p += 1
            if b == 1:
                break
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
X = input()

ans = 1
for b in range(2,X):
  t = b*b
  while True:
    if t>X:
      break
    ans = max(ans, t)
    t *= b
print ans

Submission status: Accepted

Solution code:
X = int(input())

powers = {1}
for base in range(2, int(X**0.5)+1):
    power = base * base
    while power <= X:
        powers.add(power)
        power *= base

print(max(powers))

Submission status: Accepted

Solution code:
*r,=range(1,32);x=int(input());print(max(b**p*(b**p<=x)for p in r[1:]for b in r))

Submission status: Accepted

Solution code:
EXP = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001]
X = int(input())
for i, e in enumerate(EXP):
    if e > X:
        print(EXP[i - 1])
        break

Submission status: Accepted

Solution code:
X = int(input())
beki=[]
for a in range(X):
    A=a+1
    for i in range(32):
        I=i+1
        j=0
        for j in range(9):
            J=j+2
            if A == I**J:
                beki.append(A)
                break
            elif A<I**J:
                break
print(max(beki))

Submission status: Accepted

Solution code:
int_x = int(input())

result = 0
for b in range(1, 100):

    for p in range(2, 10):

        if b ** p <= int_x:
            result = max(result, b ** p)
        else:
            break

print(result)

Submission status: Accepted

Solution code:
beki = [1]
for b in range(2,32):
    for p in range(2,10):
        if b ** p <= 1000:
            beki.append(b ** p)
beki.sort()
def inf(x,l):
    for i in range(len(l)):
        if l[i] > x:
            return l[i-1]
x = int(input())
if x == 1000:
    print(1000)
    exit()
print(inf(x,beki))

Submission status: Accepted

Solution code:
X = int(input())
max_n = 1
for i in range(2,32):
  for j in range(2,10):
    tmp = i**j
    if X >= tmp and max_n < tmp:
      max_n = tmp
print(max_n)

Submission status: Accepted

Solution code:
x = int(input())

mx = 1
for b in range(2, x + 1):
    if b ** 2 > x:
        mx = max(mx, (b - 1) ** 2)
        break
    for p in range(2,x + 1):
        if b ** p > x:
            mx = max(mx, b ** (p - 1))
            break

print(mx)

Submission status: Accepted

Solution code:
x = int(input())
result = 1

for i in range(2, 32):
    for j in range(2,10):
        test = i**j
        if test <= x and test >= result:
            result = test
        else:
            pass
          
print(result)

Submission status: Accepted

Solution code:
x=int(input())
count=0
for i in range(1,32):
    for j in range(2,10):
        s=i**j
        if s<=x and s>count:
            count=s
print(count)

Submission status: Accepted

Solution code:
x=int(input())
expo=[1]
p=2

for i in range(2,32):
    while i**p<=1000:
        expo.append(i**p)
        p+=1
    p=2

expo=set(expo)
expo=sorted(expo)

for j in range(len(expo)):
    if expo[j]<=x:
        ans=expo[j]

print(ans)

Submission status: Accepted

Solution code:
X = int(input())
list = [1,1000]
C = 2
while True:
    i = 2
    while True:
        n = C**i
        if n >= 1000:
            break
        else:
            list.append(n)
        i += 1
        #print(list)

    C += 1
    if C >= 32:
        break
#print(list)
list = sorted(list)
#print(list)
for i in range(len(list)):
    if list[len(list)-1-i] <= X:
        print(list[len(list)-1-i])
        break

Submission status: Accepted

Solution code:
X = int(input())

flag = False
for i in range(X, 0, -1):
  for j in range(2, i):
    t = i
    while True:
      if t % j != 0:
        break
      t //= j
      if t == 1:
        print(i)
        flag = True
        break
    if flag:
      break
  if flag:
    break

if flag == False:
  print(1)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(1,32):
    for j in range(2,10):
        if i**j <= n:
            a.append(i**j)
        else:
            break
            
print(max(a))

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for i in range(2,34):
    j = 2
    while True:
        if i**j>x:
            break
        ans = max(ans,i**j)
        j += 1
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

ans = 1

for i in range(2, X + 1):
    for j in range(2, X + 1):
        if X < i ** j:
            break
        ans = max(ans, i ** j)

print(ans)

Submission status: Accepted

Solution code:
x=int(input())
i=1
while i**2<=x:
    i+=1
result=(i-1)**2

i=1
while i**3<=x:
    i+=1
if (i-1)**3>result:
    result=(i-1)**3

i=1
while i**4<=x:
    i+=1
if (i-1)**4>result:
    result=(i-1)**4

i=1
while i**5<=x:
    i+=1
if (i-1)**5>result:
    result=(i-1)**5

i=1
while i**6<=x:
    i+=1
if (i-1)**6>result:
    result=(i-1)**6

i=1
while i**7<=x:
    i+=1
if (i-1)**7>result:
    result=(i-1)**7

i=1
while i**8<=x:
    i+=1
if (i-1)**8>result:
    result=(i-1)**8

i=1
while i**9<=x:
    i+=1
if (i-1)**9>result:
    result=(i-1)**9
print(result)

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for i in range(1,X+1):
  for p in [2, 3, 5, 7]:
    if(i**p <= X):
      ans = max(ans, i**p)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
l = []
for i in range(1,33):
  for j in range(2,11):
    if i**j <= x:
      l.append(i**j)
l.sort()
print(l[-1])

Submission status: Accepted

Solution code:
lst=[]
tmp=0
ans=0
x=int(input())
for j in range(1,32):
    for i in range(2,11):
        if j**i <= 1000:
            lst.append(j**i)
lst=sorted(lst)
for i in lst:
    tmp=i
    if i>x:
        print(ans)
        exit()
    ans=tmp
    if i==1000:
        print(1000)

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(1,n+1):
    for j in range(2,10):
        if i**j <= n:
            l.append(i**j)
print(max(l))

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(1,n+1):
    for j in range(2,100):
        if i**j <= n:
            l.append(i**j)
print(max(l))

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for b in range(2,X+1):
    v = 0
    v = b * b
    while True:
        if v > X:
            break
        ans = max(ans,v)
        v = v * b
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

l = []
a = 0
for i in range(32):
    for j in range(2, 9):
        a = i**j
        if a <= x:
            l.append(a)
print(max(l))

Submission status: Accepted

Solution code:
x = int(input())
l = []
a = 0
for i in range(32):
    for j in range(2,9):
        a = i**j
        if a <= x:
            l.append(a)
print(max(l))

Submission status: Accepted

Solution code:
#ABC097B
x = int(input())
ans=[1]
i =1
while i <= x//2:
    i += 1
    j = 1
    tmp = 0
    while True:
        j+=1
        tmp = i**j
#         print(i,j,tmp)
        if tmp<=x:
            ans.append(tmp)
        else:
            break
print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())
ans = []
for i in range(1, x+2):
    for l in range(2, x+2):
        if i ** l <= x:
            ans.append(i ** l)
        if i ** l > x:
            break
            

ans.sort()
print(ans[len(ans)-1])

Submission status: Accepted

Solution code:
import numpy as np
x = int(input())
result = 1

if x == 1:
    print(result)
else:
    for i in range(2, int(np.sqrt(x) + 1)):
        j = 2
        while True:
            calc = pow(i, j)
            if calc > x:
                break
            result = max([result, calc])
            j += 1
    print(result)

Submission status: Accepted

Solution code:
X = int(input())

count = []
if X == 1:
    print(1)
else:
    for i in range(1,X):
        for b in range(2,10):
            factorial = i**b
            if factorial <= X:
                count.append(factorial)

    print(max(count))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 11 05:38:56 2019

@author: shinjisu
"""


# ABC 200点問題
import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


debug = True


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def prob096():  # Maximum Sum
    X = getIntList()
    K = getInt()
    dmp((X, K))
    total = sum(X) - max(X) + max(X)*2**K
    return total


def prob097():  # Exponential
    X = getInt()
    dmp(X)
    if X == 1:
        return 1
    for n in range(X, 0, -1):
        dmp(n)
        for b in range(2, int(math.sqrt(X))+1):
            a = n
            exp = True
            while a > 1:
                if a % b != 0:
                    exp = False
                    break
                a //= b
            if exp:
                break
        if exp:
            break
    return n


debug = False
print(prob097())

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from math import sqrt,floor
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    X = int(lines.pop(0))
    s = floor(sqrt(X))
    res = 1
    for c in range(s, 1, -1):
        n = 2
        while( c**n <= X ):
            res = max(res, c**n)
            n += 1

    print(res)
#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

Solution code:
X = int(input())

if X == 1:
    print(1)
else:
    ans = 1
    for i in range(2, int(X**0.5)+1):
        b = i
        b *= i
        while b <= X:
            ans = max(ans, b)
            b *= i
    print(ans)

Submission status: Accepted

Solution code:
import math

X = int(input())
cand = [1]

for i in range(2, int(math.sqrt(X))+1):
    num = i**2
    while num <= X:
        cand.append(num)
        num *= i

print(max(cand))

Submission status: Accepted

Solution code:
x=int(input())
square=2
while square*square<x:
    square+=1
ans=0
for i in range(2,square):
    for j in range(2,square):
        if i**j>ans and i**j<=x:
            ans=i**j
if x<4:
    ans=1
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for i in range(1, X):
  for p in [2, 3, 5, 7]:
    calc = i**p
    if(calc <= X):
      ans = max(ans, calc)
print(ans)

Submission status: Accepted

Solution code:
import math
x = int(input())
s = math.floor(math.sqrt(x))
res = 0
for i in range(1,s+1):
    for j in range(1,s+1):
        if i**j<=x:
            res = max(res,i**j)
print(res)

Submission status: Accepted

Solution code:
x=int(input())
n=[]
for i in range(1,32):
  for j in range(2,10):
    d=i**j
    if d<=x:
      n.append(d)
    else:
        break
print(max(n))

Submission status: Accepted

Solution code:
import math
x=int(input())
max_b=math.floor(math.sqrt(x))
max_p=math.floor(math.log2(x))
ans=1
for b in range(max_b+1):
    for p in range(2,max_p+1):
        if b**p<=x:
            ans=max(ans,b**p)
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
ans=0
for i in range(1,100):
  for j in range(2,10):
    tmp=i**j
    if x<tmp:
      break
    ans=max(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
import collections
def inpl(): return list(map(int, input().split()))

#### START
X = int(input())
l = []
for i in range(1, 1000):
  for j in range(2, 11):
    if not i**j in l:
      l.append(i**j)

l.sort(reverse=True)
for i in l:
  if i<=X:
    print(i)
    break

Submission status: Accepted

Solution code:
x=int(input())
ans=1
for j in range(2,11):
    i=1
    while i**j<=x:
        ans=max(ans,i**j)
        i+=1
print(ans)

Submission status: Accepted

Solution code:
X=int(input())
n_max=0
for i in range(int(X**0.5)+1):
  if(X==1):
    n_max=1
    break
  else:
    for j in range(X):
      if((i+1)**(j+1)>X):
        #print('i='+str(i+1)+' j='+str(j))
        #print((i+1)**j)
        n_max=max(n_max,(i+1)**j)
        break
print(n_max)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    if X == 1:
        print(1)
    else:
        for x in range(X, 0, -1):
            for b in range(2, X):
                p = 2
                while True:
                    if b ** p > x:
                        break
                    if x == b ** p:
                        print(x)
                        exit()
                    p += 1


main()

Submission status: Accepted

Solution code:
X = int(input())

powers = {1}
for base in range(2, int(X**0.5)+1):
    power = base
    while power <= X:
        powers.add(power)
        power *= base

print(max(powers))

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for x in range(2, 32):
    for i in range(2, 10):
        if x ** i <= X:
            ans = max(ans, x ** i)
print(ans)

Submission status: Accepted

Solution code:

n = int(input())

ans = 0
for i in range(1, 31+1):
    for p in range(2, 9 + 1):
        t = i ** p
        if t <= n:
            ans = max(t,ans)

print(ans)

Submission status: Accepted

Solution code:
import sys
x = int(input())

m = 0
for i in range(33):
  for j in range(2,11):
    if i**j<=x:
      m = max(m,i**j)
print(m)

Submission status: Accepted

Solution code:
def main():
    n = int(input())

    ans = [1]
    for i in range(2, n + 1):
        j = 2
        while i ** j <= n:
            ans.append(i ** j)
            j += 1

    print(max(ans))


def main2():
    n = int(input())
    ans = 1
    for i in range(2, n + 1):
        j = 2
        while pow(i, j) <= n:
            ans = max([ans, pow(i, j)])
            j += 1

    print(ans)


if __name__ == '__main__':
    main2()

Submission status: Accepted

Solution code:
def main():
    n = int(input())

    # for i in range(1, n + 1):
    #     if

    # i = 1
    # while i * i <= n:
    #     i += 1
    #
    # print((i - 1) ** 2)

    ans = [1]
    for i in range(2, n + 1):
        j = 2
        while i ** j <= n:
            ans.append(i ** j)
            j += 1

    print(max(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
"""AtCoder"""

X = int(input())

l = []

for i in range(33):
    l.append(i**2)
for i in range(11):
    l.append(i**3)
for i in range(7):
    l.append(i**4)
for i in range(6):
    l.append(i**5)
for i in range(4):
    l.append(i**6)
for i in range(7,10):
    l.append(2**i)

while X not in l:
    X -= 1

print(X)

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for b in range(1,32):
	for p in range(2,10):
		l = b**p
		if l <= x and l > ans:
			ans = l
print(ans)

Submission status: Accepted

Solution code:
import math

X = int(input())
n = int(math.sqrt(X))

ret = 1
for x in range(2, n + 1):
    p = 2
    while X >= x ** p:
        ret = max(ret, x ** p)
        p += 1
print(ret)

Submission status: Accepted

Solution code:
X = int(input())
A = [False]*1001
A[1] = True
for i in range(2,1001):
    j = 2
    while i**j < 1001:
        A[i**j] = True
        j += 1

ans = 1
for i in range(X,-1,-1):
    if A[i]:
        ans = i
        break

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
x = int(input())

def judge(n):
    ok = True
    a = Counter()
    i = 2
    num = 0
    while(n>i):
        if n%i == 0:
            while(n%i==0):
                a[i] += 1
                n //= i
            num = a[i]
        i += 1
    if n > 1:
        a[n] += 1
    for p in a:
        if a[p] != num or num == 1:
            ok = False
    return ok

for i in range(1,x+1)[::-1]:
    if judge(i):
        print(i)
        break

Submission status: Accepted

Solution code:
x=int(input())
a=1
for i in range(2,11):
    for j in range(1,x+1):
        if j**i<=x:
            a=max(a,j**i)
print(a)

Submission status: Accepted

Solution code:
x=int(input())
a=1
for i in range(2,11):
    for j in range(1,x):
        if j**i<=x:
            a=max(a,j**i)
print(a)

Submission status: Accepted

Solution code:
X = int(input())
L=[]
for i in range(2,11):
    for j in range(1001):
        if j**i > 1000:
            break
        if  j**i not  in L:
            L.append(j**i)
L=sorted(L)

if  X not in L:
    L.append(X)
    L=sorted(L)
    n = L.index(X)
    print(L[n-1])
else:
    print(X)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
for b in range(1,35):
  for p in range(2,11):
    if b**p <=x:
      ans = max(b**p,ans)
print(ans)

Submission status: Accepted

Solution code:
X=int(input())
dp=[False]*(X+1)
dp[1]=True
for p in range(2,int(1000**0.5)+1):
    n=p*p
    while n<=X:
        dp[n]=True
        n*=p
for ans in range(X,0,-1):
    if dp[ans]==True:
        print(ans)
        break

Submission status: Accepted

Solution code:
x = int(input())
n = 1
p =2
res = 1
while (2**p<=x):
    while (n**p<=x):
        n += 1
    res = max(res,(n-1)**p)
    p += 1
    n = 1
print(res)

Submission status: Accepted

Solution code:
X = int(input())
beki = [1]
for i in range(2, 34):
    a = i * i
    while a <= X:
        beki.append(a)
        a *= i
print(max(beki))

Submission status: Accepted

Solution code:
def function(X):
    B = list(range(31, 0, -1))
    res = 0
    for b in B:
        p = 2
        cp = p
        while True:
            tmp = b ** p
            if tmp > X:
                break
            else:
                res = max(res,tmp)
                if b == 1: break
                cp = p
                p += 1
    return res

X = int(input())
print(function(X))

Submission status: Accepted

Solution code:
def main(x):
    tmp = 0
    for i in range(1, 1001):
        for j in range(2, 11):
            if i ** j > x: break
            if i ** j > tmp: tmp = i ** j
    print(tmp)


if __name__ == '__main__':
    main(int(input()))

Submission status: Accepted

Solution code:
x = int(input())

if x == 1:
  print(1)
else:
  i = 2
  maxp = 2
  while i*i <= x:
    j = 1
    while pow(i, j) <= x:
      j += 1
    maxp = max(maxp, pow(i, j-1))
    i += 1
  print(maxp)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
if x == 1:
    ans = 1
else:
    for i in range(2, 100):
        n = 2
        while i ** n <= x:
            ans = max(ans , i ** n)
            n += 1
            
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
for i in range(1, 1000):
    for j in range(2, 10):
        if i ** j <= x:
            ans = max(i ** j, ans)
            
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for i in range(2, x // 2):
    n = i
    while n <= x:
        ans = max(ans, n)
        n *= i
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
a = 1
for i in range(2,x):
    j = 2
    while i**j <= x:
        a = max(a,i**j)
        j += 1
print(a)

Submission status: Accepted

Solution code:
x = int(input())
a = 1
for i in range(1,x):
    for j in range(2,x):
        if i**j <= x:
            a = max(a,i**j)
        else:
          break
print(a)

Submission status: Accepted

Solution code:
x = int(input())
a = 0
for i in range(1,x+1):
    for j in range(2,10):
        if i**j <= x:
            a = max(a,i**j)
print(a)

Submission status: Accepted

Solution code:
n = int(input())
a = 1
for i in range(1,n):
    for j in range(2,n):
        if i**j <= n:
            a = max(a,i**j)
        else:
            break


print(a)

Submission status: Accepted

Solution code:
X = int(input())
res = 1
x=int(X**0.5+1)
for i in range(2,x):
    t = i**2
    while t<=X:
        t = t*i
    res = max(res,t//i)
print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import math

def main():
    X = int(input())

    ex = []

    b = int(math.sqrt(X))
    ex.append(b * b)
    for b in range(2, 11):
        for p in range(3, 10):
            if b ** p <= X:
                ex.append(b ** p)
            else:
                break

    print(max(ex))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
a=int(input())
b=[]
for i in range(2,11):
    if math.ceil(a**(1/i))>=2:
        b.append((math.ceil(a**(1/i))**i if math.ceil(a**(1/i))**i<=a else math.floor(a**(1/i))**i))
print(max(b)if a>3else 1)

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
if X == 1: print(1)
else:
    for i in range(2, X):
        if i*i <= X:
            a = i
            while a*i <= X:
                a *= i
            ans = max(ans, a)
    print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ans=1
for i in range(2,N):
  temp=i
  while temp*i <= N:
    temp=temp*i
    ans=max(ans,temp)
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

n = 1
ans = 1
for b in range(X):
    if b== 0 or b == 1:
        continue
    p = 2
    while b ** p <= X:
        n = b ** p
        p += 1
    if ans < n:
        ans = n
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
n=[]
for i in range(1,32):
  for j in range(2,10):
    if i**j<=x:
      n.append(i**j)
print(max(n))

Submission status: Accepted

Solution code:
X = int(input())
max_num = 1
for i in range(1,X+1):
  for p in [2,3,5,7]:
    calc = i**p
    if(calc <= X):
      max_num = max(max_num, calc)
print(max_num)

Submission status: Accepted

Solution code:
n = int(input())
A = []
for i in range(1, n+1):
    for j in range(2, 11):
        ans = i**j
        if(ans<=n):
            A.append(ans)
print(max(A))

Submission status: Accepted

Solution code:
X = int(input())
m = 0
for b in range(1,40):
    for p in range(2,15):
        t = b ** p
        if t <= X:
            m = max(m, t)

print(m)

Submission status: Accepted

Solution code:
import math
x = int(input())
h = math.floor(math.sqrt(x))
c = []
for i in range(h+1):
    for j in range(h+1):
        if i**j<=x:
            c.append(i**j)
print(max(c))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
import math
input = sys.stdin.readline

X = int(input())
val = int(math.sqrt(1000)) + 1

ans = 1
for p in range(2, 10):
    for b in range(1, val):
        tmp = max(ans, pow(b, p))
        if tmp > X:
            break
        ans = tmp
print(ans)

Submission status: Accepted

Solution code:
X=int(input())

if X<4:
    print('1')
    exit(0)

n=2
p=2
max=0
b_flag=True
while True:
    n+=1
    #print(n)
    while True:
        if n**p>X:
            break
        elif max<n**p:
            max=n**p
        p+=1

    p = 2
    b_flag=True
    if n**p>X:
        break
print(max)

Submission status: Accepted

Solution code:
X = int(input())
bekijou = []
for i in range(int(pow(X+1, 1/2))+1):
    for j in range(10):
        if i ** j <= X:
            bekijou.append(i ** j)
print(max(bekijou))

Submission status: Accepted

Solution code:
X=int(input())
check=0
maxx=0

if(X<=3):
    print(1)
    quit()

for i in range(2,1001):
    for j in range(2,1001):
       check=i**j
       if(check>X):
           break
       if(maxx<check ):
           maxx=check

print(maxx)

Submission status: Accepted

Solution code:
X = int(input())
ans = []

for i in range(34):
  for j in range(2,11):
    if pow(i,j) <= X: 
      ans.append(pow(i,j))
    else:
      break

ans.sort(reverse= True)

for i in ans:
  if i <= X:
    print(i)
    break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    x = int(input())

    max_val = 0
    min_diff = 1000
    for i in range(1, 32):
        for j in range(2, 10):
            temp = i ** j
            if temp > x:
                break
            else:
                temp_dif = x - temp
                if temp_dif < min_diff:
                    min_diff = temp_dif
                    max_val = temp

    print(max_val)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
X=int(input())

n=int(math.sqrt(X))
ans=0

if(X==1 or X==2 or X==3):
    print(1)
else:
    for i in range(2,n+1):
        j=2
        while(i**j<=X):
            if(i**j>ans):
                ans=i**j
            j+=1
    print(ans)

Submission status: Accepted

Solution code:
x=int(input())
while sum(round(x**(1/k))**k!=x for k in [2,3,5,7])==4:
  x-=1
print(x)

Submission status: Accepted

Solution code:
x=int(input())
while round(x**0.5)**2!=x and round(x**(1/3))**3!=x and round(x**(1/5))**5!=x and round(x**(1/7))**7!=x:
  x-=1
print(x)

Submission status: Accepted

Solution code:
X = int(input())

if X < 4:
    ans = 1
else:
    ans = 2 ** 2
    for b in range(2, X + 1):
        p = 2
        while True:
            tmp = b ** p
            if tmp <= X:
                ans = max(ans, tmp)
                p += 1
            else:
                break

print(ans)