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:
N=int(input())
q=1
if N==1000:
    print(1000)
    exit()
for i in range(0,N):
    for j in range(2,10):
        s=(N-i)**(1/j)
        if s==s//1:
            q=max(N-i,q)
print(q)

Submission status: Accepted

Solution code:
n = int(input())
result = pow(int(n**(1/2)), 2)
for b in range(1, n):
  for p in range(2, n):
    if b**p > n:
        break
    elif b**p > result:
        result = b**p

print(int(result))

Submission status: Accepted

Solution code:
X=int(input())
p=2
k=1
l=[]
while p<10:
    while k**p<=X:
        k+=1
    l.append((k-1)**p)
    p+=1
    k=1
print(max(l))

Submission status: Accepted

Solution code:
x = int(input())

i = 1
ans = 1
if x <= 4:
    ans = 1
else:
    i = 2
    while i <= x:
        j = 2
        while i**j <= x:
            if ans < i**j:
                ans = i**j
            j = j+1
        i = i+1

print(ans)

Submission status: Accepted

Solution code:
import collections


def prime_decomp(j):
    if j == 1:
        return [1]

    num = j
    s = 0
    R = int(num)
    L = []
    while s == 0:
        for i in range(2, R+1):
            if num % i == 0:
                num = num/i
                if num == 1:
                    s = 1
                L.append(i)
                break

    return L


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

    for t in range(x):
        y = x - t
        nums = prime_decomp(y)
        counter = collections.Counter(nums)

        if y == 1000:
            print(1000)
            exit()

        if len(counter) == 1:
            for key, val in counter.items():
                if val == 1:
                    continue

                else:
                    print(y)
                    exit()

        ans = True
        for key, val in counter.items():
            if val % 2 != 0:
                ans = False

        if ans:
            print(y)
            exit()

    print(1)

Submission status: Accepted

Solution code:
N = int(input())
s = set()
for a in range(1,35):
    for b in range(2,11):
        if a ** b > N : continue
        else: s.add(a**b)
print(max(s))

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
import math

x = int(input())

t = math.floor(math.sqrt(x))

amax = 1
for i in range(t - 1):
    a = 1
    n = 1
    while a <= x:
        if amax < a:
            amax = a
        a = (i + 2) ** n
        n += 1

print(amax)

Submission status: Accepted

Solution code:
#coding:utf-8


X = int(raw_input())


lists = []

for i in range(11, 32):
    lists.append(i ** 2)

for i in range(6, 11):
    lists.append(i ** 2)
    lists.append(i ** 3)

for i in range(4, 6):
    lists.append(i ** 2)
    lists.append(i ** 3)
    lists.append(i ** 4)

for i in range(3, 4):
    lists.append(i ** 2)
    lists.append(i ** 3)
    lists.append(i ** 4)
    lists.append(i ** 5)

for i in range(1, 10):
    lists.append(2 ** i)

lists.append(1)

max_num = 0
for i in lists:
    if (max_num < i) and (i <= X):
        max_num = i

print max_num

Submission status: Accepted

Solution code:
from math import ceil, sqrt
x = int(input())

def can_exp(x):
    if x==1:
       return True
    d = []
    for i in range(2,ceil(sqrt(x))+1):
        if x%i!=0:
            continue
        n = 0
        while x%i==0:
            n += 1
            x //= i
        d.append(n)
    if x!=1:
        d.append(1)
    m = d[0]
    for e in d[1:]:
        m = gcd(m,e)
    return m>1

def gcd(a,b):
        while b!=0:
            a,b = b, a%b
        return a

for i in range(x,0,-1):
    if can_exp(i):
        print(i)
        break

Submission status: Accepted

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

X = int(input())
sq = int(math.sqrt(1000))

ans = 1
for i in range(2, sq+1):
    for j in range(2, sq+1):
        if i ** j <= X and ans < i ** j:
            ans = i ** j
            continue
print(ans)

Submission status: Accepted

Solution code:
def main():
    
    inp = input()
    x = int(inp.strip())

    maxi = 1
    for i in range(1, x):
        for j in range(2, 11):
            if i ** j <= x:
                maxi = max(maxi, i**j)
    
    print(maxi)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=int(input())
max=0
if a==1 :
    print(a)
    exit()
for i in range(a):
    for j in range(a):
        p=i**(j+2)
        if p>a : break
        if p>max:
            max=p
    if max==a :break
print(max)

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
import math   

def main():
    #0.input
    X = int(input())
    
    #exception
    if X<4:
        print(1)
    
    #other.
    else:
        #1. list up numbers lt sqrt
        nums = [i for i in range(2, int(math.sqrt(X)+1))]
        
        #2. list up power nums
        candidates=[]
        for n in nums:
            cand = n
            while cand*n <= X:
                cand *= n
            candidates.append(cand)
        
        #3.output
        print(max(candidates))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

x = int(input())
maxans = 1
for i in range(1, int(math.sqrt(x))):
    tmp = 0
    while (i+1)**tmp <= x:
        b = (i+1)**tmp
        if maxans < (i+1)**tmp: maxans = (i+1)**tmp
        tmp += 1

print(maxans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
X = int(input())
ans = []
for i in range(1,33):
    for j in range(2, 10):
        # print(i,j)
        if X >= pow(i,j):
            ans.append(pow(i,j))
# print(ans)
print(max(ans))

Submission status: Accepted

Solution code:
Num = [ 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]

N = int(input())

out = 1

for i in Num:
    if i<=N:
        out = i
    else:
        break

print(out)

Submission status: Accepted

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

for p in range(2, 11):
    n = 1
    while(n**p <= x):
        if(max_num < n**p):
            max_num = n**p
        n += 1

print(max_num)

Submission status: Accepted

Solution code:
X = int(input())

ts = [False for x in range(X+1)]
ts[1] = True

for i in range(2,int(X ** 0.5) + 1):
    k = 2
    while i ** k <= X:
        ts[i**k] = True
        k += 1

for i in range(X,-1,-1):
    if ts[i]:
        print(i)
        break

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

x = ni()
max = 1
a = [2,3,4,5,6,7,8,9]

for i in range(1, x+1):
    for j in a:
        if i**j <= x and i**j > max:
            max = i**j
print(max)

Submission status: Accepted

Solution code:
x = int(input())
m =0
for i in range(2,11):
    m=max(m,int(((x**(1/i)+0.000001)//1)**i))
print(m)

Submission status: Accepted

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

for i in range(1,32):
    for j in range(2,10):
        if i**j <= 1000:
            a.append(i**j)
a_uni = list(set(a))
b = sorted(a_uni)
    
max = 0
for i in b:
    if i <= X:
        max = i
print(max)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
candidate = []
# べき乗リストを更新する
for i in range(32):
    if i >= 1:
        for j in range(32):
            if i**j <= 1000:
                if j > 1:
                    if i**j not in candidate:
                        candidate.append(i**j)
            else:
                break

candidate = sorted(candidate)
x = int(input())
result = 1
for c in candidate[1:]:
    if x >= c:
        result = c
    else:
        break
print(result)

Submission status: Accepted

Solution code:
X = int(input())

numberOfPowers = set([1])

for i in range(2, 33):
    j = 2
    while True:
        numberOfPowers.add(i**j)
        j += 1
        if (i ** j > 1000):
            break

ans = 0
for i in sorted(numberOfPowers):
    if i > X:
        break
    ans = i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
res = 1
for i in range(1, n):
    for j in range(1, n):
        if i**j > n:
            if res < i**(j-1):
                res = i ** (j-1)
            break
    if i**2 > n:
        break
print(res)

Submission status: Accepted

Solution code:
X = int(input())
b=1
MAX=1
if X!=1:
    while b<X/2:
        p=2
        b+=1
        while b**p <= X:
            if b**p > MAX:
                MAX = b**p
            p+=1
print(MAX)

Submission status: Accepted

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

lim = int(X**(1/2))

listx =[]

if X == 1 or X == 2 or X ==3:
    print(1)
    sys.exit()

if X >= 4 and X <= 8:
    print(4)
    sys.exit()

for i in range(lim+1):
    if i == 0 or i ==1:
        continue
    a = i
    p = 0
    while a <= X:
        a = i ** p
        p += 1
    listx.append(i**(p-2))

print(max(listx))

Submission status: Accepted

Solution code:
X = int(input())
max_fs = 1

for x in range(2, X + 1):
    for p in range(2, 10):
        if x ** p <= X:
            max_fs = max(max_fs, x ** p)
        else:
            break
print(max_fs)

Submission status: Accepted

Solution code:
import math

X=int(input())

y=math.floor(math.sqrt(X))

L=[0 for i in range(y+1)]

for i in range(2,y+1):
    count=1
    while True:
        n=i**count
        if n<=X:
            count+=1
        else:
            break
    L[i]=i**(count-1)

if X<=3:
    print(1)
else:
    print(max(L))

Submission status: Accepted

Solution code:
X = int(input())

exponential = {1}
for i in range(2, 32):
    for j in range(2, 11):
        if i ** j <= X:
            exponential.add(i ** j)
        else:
            break
print(max(exponential))

Submission status: Accepted

Solution code:
import math
n=int(input())
#a,b,c,d=map(int,input().split())
k=pow(n,0.5)
ans=1
if(n<=3):
	print(1)
else:
	ans=-1
	for i in range(1,n+1):
		for j in range(2,n+1):
			if(pow(i,j)<=n):
				if(ans<pow(i,j)):
					ans=pow(i,j)
				
			else:
				break
	print(ans)

Submission status: Accepted

Solution code:
import math
x = int(input())
r = [1]
for y in range(2, int(math.sqrt(x)) + 1):
    z = 2
    tmp = 1
    while math.pow(y, z) <= x:
        tmp = int(math.pow(y, z))
        z += 1
    r.append(tmp)
print(max(r))

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for i in range(x, 0, -1):
    if i == 1:
        ans = 1
        break
    tmp = i
    for j in range(31, 1 ,-1):
        i = tmp
        #print(i,j)
        flag = 0
        while(i > 1):
            i = i/j
            flag += 1
            if i == 1 and flag > 1:
                ans = tmp
                break
        if ans != 0:
            break
    if ans != 0:
        break
print(ans)

Submission status: Accepted

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

if X < 2**2:
  print(1)
  exit()
  
for b in range(2, 32):
    p = 2
    if b ** p > X:
      continue
    while b ** (p+1) <= X:
        p += 1
    ans = max(ans, b**p)

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
l = sorted(set([x ** y for y in range(2,20) for x in range(1,100) if x**y <= 1000]))

print(max([n for n in l if n <= x]))

Submission status: Accepted

Solution code:
x = int(input())
max = 0
if x == 1:
    print(1)
    exit()
for b in range(1, 1001):
    for p in range(2, 10):
        if b**p <= x:
            if b**p >= max:
                max = b**p
print(max)

Submission status: Accepted

Solution code:
X = int(input())

max_val = 0

if X == 1:
    max_val = 1

for b in range(2,X):
    p = 2
    while(True):
        val = b ** p
        if val > X:
            break
        if val >= max_val:
            max_val = val
        p += 1

print(max_val)

Submission status: Accepted

Solution code:
import sys
import math
if __name__ == "__main__":
    X = int(input())
    buf = int(math.sqrt(X))
    buf = pow(buf, 2)
    for i in range(2, 11):
        tmp = pow(i, 3)
        if tmp <= X and tmp > buf:
            buf = tmp
    for i in range(2, 6):
        tmp = pow(i, 4)
        if tmp <= X and tmp > buf:
            buf = tmp
    for i in range(2, 4):
        tmp = pow(i, 5)
        if tmp <= X and tmp > buf:
            buf = tmp
    for i in range(2, 4):
        tmp = pow(i, 6)
        if tmp <= X and tmp > buf:
            buf = tmp
    for i in range(7, 11):
        tmp = pow(2, i)
        if tmp <= X and tmp > buf:
            buf = tmp
    print(buf)

Submission status: Accepted

Solution code:
import math

X = int(input())
logX = int(math.log2(X))+10
value = 0
for i in range(2,logX):
    for j in range(1,X+1):
        value_temp = j ** i
        if value_temp <= X:
            value = max(value,value_temp)
print(value)

Submission status: Accepted

Solution code:
X = int(input())

for i in range(X, 0, -1):
    for j in range(31, 0, -1):
        for k in range(9, 1, -1):
            if pow(j, k) == i:
                print(i)
                exit()

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:
#coding: utf-8
import math
x=int(input())
r=math.floor(math.sqrt(x))
i=2
j=2
ans=1
while(i<=r):
    while(i**j<=x):
        j+=1
    if(i**(j-1)>ans):
        ans=i**(j-1)
    j=2
    i+=1
print(ans)

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    x = int(input())
    value = 0

    for i in range(100):
        for j in range(2, 10):
            tmp = pow(i, j)
            if tmp <= x and tmp > value:
                value = tmp

    print(value)

Submission status: Accepted

Solution code:
X = int(input())

if X==1:
    print(X)
    exit()

ans = 1
for b in range(2,33):
    for p in range(2,10):
        if b**p > ans and b**p <= X:
            ans = b**p

print(ans)

Submission status: Accepted

Solution code:
# coding : utf-8
import math

X = int(input())

x_sqrt = math.ceil(math.sqrt(X))
ans = 1
calcEnd = False
for i in range(X, 0, -1):
    for j in range(x_sqrt, 1, -1):
        calc = j
        while calc <= i:
            calc *= j

            if calc == i:
                ans = i
                calcEnd = True
                break

        if calcEnd:
            break
    if calcEnd:
        break

print(ans)

Submission status: Accepted

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

X = int(input())

b=[1]
for i in range(1,X):
    for j in range(2,X):
        if i**j > X:
            break
        else:
            b.append(i**j)
print(max(b))

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for i in range(1,100):
    for j in range(2,15):
        if pow(i,j) <=x:
            ans = max(ans,pow(i,j))
print(ans)

Submission status: Accepted

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

X = int(input())

bmax = round(math.sqrt(X))

bp = 1
for b in range(2, bmax + 1, 1):
    p = 2
    while(pow(b, p) <= X):
        p += 1
    p += -1
    if(bp < pow(b, p)):
        bp = pow(b, p)

print(bp)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    X = int(input())

    if X == 1:
        print("1")
        exit(0)
    if X == 1000:
        print("1000")
        exit(0)

    candidates = []
    for b in range(2, 31 + 1):
        p = 1
        while True:
            p += 1
            value = b ** p
            if value <= 1000:
                candidates.append(value)
            else:
                break

    candidates = sorted(set(candidates))
    for i in range(len(candidates) - 1):
        if candidates[i] <= X and X < candidates[i + 1]:
            print(candidates[i])
            exit(0)

Submission status: Accepted

Solution code:
X = int(input())
num = 1
max = 0
for i in range(1,X):
    for j in range(2,X):
        num = i ** j
        if num > X:
            break
        if max < num:
            max = num
if max != 0:
    print(max)
else:
    print(1)

Submission status: Accepted

Solution code:
#coding: utf-8
import math

x = int(input())

maxcount = int(math.sqrt(x))

result = 0
for i in range(1,maxcount+ 1):
    j = 0
    while True:
        tmp = i ** (maxcount - j)
        j += 1
        if tmp > x:
            continue
        else:
            break
    if tmp > result and tmp <= x:
        result = tmp

print(result)

Submission status: Accepted

Solution code:
# your code goes here

import math

N = int(input())

exp = [1]
for i in range(2,int(math.sqrt(N))+1):
	if pow(i,int(math.log(N,i))+1) <= N:
		exp.append(pow(i,int(math.log(N,i))+1))
	else:
		exp.append(pow(i,int(math.log(N,i))))
print(max(exp))

Submission status: Accepted

Solution code:
import math

X = int(input())
max_x = 0

for i in range(2, 1000):
    pow_x = i * i
    while pow_x <= X:
        max_x = max(max_x, pow_x)
        pow_x *= i

print(max(max_x, 1))

Submission status: Accepted

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

    for i in range(6,33):
        for j in range(2,4):
            num = i**j
            if num <= x:
                lst.append(num)
    lst.sort()
    ans = lst[-1]
    print(ans)

Submission status: Accepted

Solution code:
from math import sqrt, floor

X = int(input())

if X in (1, 2, 3):
    print(1)
    exit(0)


max_beki = 1
base_list = [i for i in range(2, floor(sqrt(X)) + 1)]

for base in base_list:
    beki = base
    while beki <= X:
        beki *= base
        if beki > max_beki and beki <= X:
            max_beki = beki

print(max_beki)

Submission status: Accepted

Solution code:
X = int(input())

prime_num = range(2, 32)
num_list = [1]

for p in prime_num:
    i = 2
    while p ** i <= X:
        i += 1
    if i > 2:
        num_list += [p ** (i - 1)]

print(max(filter(lambda x: x <= X, num_list)))

Submission status: Accepted

Solution code:
num = int(input(''))

maxnum = 1
for i in range(2, int(num ** (1/2) + 1)):
    j = 2
    while True:
        if i ** j > num:
            break
        if i ** j > maxnum:
            maxnum = i ** j
            j += 1
        else:
            j += 1

print(maxnum)

Submission status: Accepted

Solution code:
x = int(input())

ret = [1]

for b in range(2, x):
    num = 0
    p = 2
    while(num < x):
        num = b**p
        p += 1
        if num <= x:
            ret.append(num)

print(max(ret))

Submission status: Accepted

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

x = int(input())

ans = 1
for b in range(1, 1001):
    for p in range(2, 11):
        result = pow(b, p)
        if result <= x:
            ans = max(ans, result)
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
th=1000
v=[1]
for b in range(2,32):
  p=2
  while b**p <= th:
    v.append(b**p)
    p+=1

v=sorted(list(set(v)))
X=int(input())
m=0
for i in range(len(v)):
  if v[i] <= X and m < X:
    m = v[i]

print(m)

Submission status: Accepted

Solution code:
x=int(input())
ans=0
s=[]
s.append(1)
for i in range(2,32):
  num=i
  while num<=1000:
    num=num*i
    s.append(num)
s=sorted(s)
flag=False
for i in range(len(s)):
  if s[i]>x:
    ans=s[i-1]
    flag=True
    break
if flag:
  print(ans)
else:
  print(s[-1])

Submission status: Accepted

Solution code:
import math

X = int(input())

candidate = 1
for b in range(1, 101):
    for p in range(2, 10):
        temp = b ** p
        if temp > X:
            break
        candidate = max(temp, candidate)
print(candidate)

Submission status: Accepted

Solution code:
X=int(input())
max=1
for i in range (1,100):
    for j in range (2,100):
        if X>=i**j and i**j>max:
            max=i**j    
print (max)

Submission status: Accepted

Solution code:
X = int(input())
ans_list = [1] * 10
for i_beki in range(1, 10):
    for i in range(1, X):
        if i ** i_beki > X:
            ans_list.append((i - 1) ** i_beki)
            break

print(max(ans_list))

Submission status: Accepted

Solution code:
SET={1}
for i in range(2,10+1):
    x=2**i
    s=2
    while x<=1000:
        SET=SET|{x}
        s+=1
        x=s**i
LIST=list(SET)
X=int(input())

print(max([y for y in LIST if y<=X]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# kakomon toku
import math
import sys
import itertools
import numpy as np

n = int(input())

a=[0]*1001  # リスト

for i in range(1,33):
    for j in range(2,10):
        k = i ** j
        if k > 1000:
            break
        else:
            a[k] = 1

for i in range(n,0,-1):
    if(a[i]==1):
        print(i)
        break

Submission status: Accepted

Solution code:
X = int(input())

ans = 1
for i in range(int(X**0.5)+5, 1, -1):
    p = 2
    while True:
        if i ** p <= X:
            ans = max(ans, i**p)
            p += 1
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
x = int(input())

_max = 0
for i in range(1, x + 1):
	for j in range(2, 1000):
		num = i**j
		if num > x:
			break
		else:
			_max = num if num > _max else _max

print(_max)

Submission status: Accepted

Solution code:
n=int(input())
beki=[1,4,8,9,16,16,25,27,32,36,49,64,64,64,81,81,100,121,125,128,144,169,196,216,225,243,256,256,256,289,324,343,361,400,441,484,512,512,529,576,625,625,676,729,729,729,784,841,900,961,1000]
ans=0
for i in range(len(beki)):
   if beki[i]<=n:
       ans=max(ans, beki[i])

print(ans)

Submission status: Accepted

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

import math

x = int(input())

if x < 4:
    print(1)
else:
    p_max = int(math.sqrt(x))
    res = 0

    for n in range(2, p_max + 1, 1):
        tmp = n
        while tmp * n <= x:
            tmp = tmp * n
            if tmp > res:
                res = tmp

    print(res)

Submission status: Accepted

Solution code:
X=input()
a=set()
for b in range(1,100):
	for p in range(2,100):
		if b**p<=X:
			a.add(b**p)
		else:
			break

print max(a)

Submission status: Accepted

Solution code:
X = int(input())
for i in range(40):
  if i*i > X:
    a = i-1
    break
ans2 = a*a
for i in range(40):
  if i **3 > X:
    b = i-1
    break
ans3 = b**3
for i in range(40):
  if i **4 > X:
    b = i-1
    break
ans4 = b**4
for i in range(40):
  if i **5 > X:
    b = i-1
    break
ans5 = b**5
for i in range(40):
  if i **6 > X:
    b = i-1
    break
ans6 = b**6
for i in range(40):
  if i **7 > X:
    b = i-1
    break
ans7 = b**7
for i in range(40):
  if i **8 > X:
    b = i-1
    break
ans8 = b**8
for i in range(40):
  if i **9 > X:
    b = i-1
    break
ans9 = b**9
print(max(ans2,ans3,ans4,ans5,ans6,ans7,ans8,ans9))

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for b in range(2,X//2):
  tmp = b**2
  while tmp <= X:
    ans = max(ans,tmp)
    tmp *= b
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    X = int(stdin.readline().rstrip())
    result = 1
    for b in range(1, X + 1):
        for p in range(2, X):
            if b ** p <= X:
                result = max(result, b ** p)
            else:
                break
        if b ** 2 > X:
            continue
    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
X = int(input())
x = int(math.sqrt(X))
maxVal = x
for i in range(2, x+1):
    val = i
    while val <= X:
        val *= i
    val = int(val/i)
    if val > maxVal:
        maxVal = val
print (maxVal)

Submission status: Accepted

Solution code:
s = [x**i for x in range(1,101) for i in range(2, 101)]
a = set(s)
x = int(input())
for u in range(x, 0, -1):
    if u in a:
        print(u)
        exit(0)

Submission status: Accepted

Solution code:
x = int(input())
table = [1]
for i in range(2,1000):
	b = 2
	while i**b <= 1000:
		table.append(i**b)
		b += 1
table.sort()
k = 0
while k <= len(table)-1 and table[k] <= x:
	k += 1
print(table[k-1])

Submission status: Accepted

Solution code:
import math
n = int(input())
a = int(n**0.5)+1
b = int(math.log2(n))+1
ans = 1

for i in range(2,a):
    for j in range(2,b):
        if n >= i**j:
            ans = max(ans,i**j)

print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	x = int(input())

	m = 0;
	for b in range(1, 1000):
		for p in range(2, 10):
			candi = b**p
			if candi > x:
				break
			if candi > m:
				m = candi

	print(m)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for i in range(2,33):
    for j in range(2,11):
        if i ** j > x:
            break
        else:
            ans = max(ans, i**j)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
import bisect
exp_list = []
for i in range(1,32):
    for j in range(2,10):
        if pow(i,j) <= 1000:
            exp_list.append(pow(i,j))
        else:
            break
exp_list.sort()
i = bisect.bisect_right(exp_list,X)
print(exp_list[i-1])

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    if X == 1000:
        return 1000

    beki = [1,]
    for i in range(2,35):
        for j in range(2,11):
            if i**j<= 1000:
                beki.append(i**j)
    beki.sort()
    for i in range(len(beki)):
        if beki[i]>X:
            return beki[i-1]

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
X = int(input())

m = 0
for b in range(1, 100):
    for p in range(2, 20):
        val = b ** p
        if val > 1000:
            continue
        if m < val <= X:
            m = val
        # print(val)

print(m)

Submission status: Accepted

Solution code:
X = int(input())
powers = [1] + [2**i for i in range(2,10)] + [3**i for i in range(2,7)] + [5**i for i in range(2,5)] + [6**i for i in range(2,4)] + [7**i for i in range(2,4)] + [10**i for i in range(2,4)] + [a**2 for a in range(11,32)]
Y =filter(lambda n:n<=X, powers)
print(max(Y))

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for i in range(2,int(X/2 + 1)):
    for j in range(2,11):
        c = i ** j
        if c <= X and c > ans:
            ans = c

print(ans)

Submission status: Accepted

Solution code:

X = int(input())
primes = [2,3,5,7,11,13,17,19,23,29,31]
res = 0
for p in primes:
    for i in range(32):
        if i**p <= X:
            res = max(i**p, res)
        else:
            break
print(res)

Submission status: Accepted

Solution code:
X = int(input())

s = [1]
for i in range(X+1):
    for j in range(2,X+1):
        if i**j <= X and i**j not in s:
            s.append(i**j)
        if i**j > X:
            break
print(max(s))

Submission status: Accepted

Solution code:
x = int(input())

num = -1

for i in range(32):
    for j in range(10):
        if (i+1) ** (j+2) >= num and (i+1) ** (j+2) <= x:
            num = (i+1) ** (j+2)

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(400):
    for j in range(2,30):
        a = i**j
        if a > X:
            continue
        elif nmax < a:
            nmax = a
            
print(nmax)

Submission status: Accepted

Solution code:
import math
x = int(input())
ans = 0
if x == 1:
    print(1)
    exit()
for i in range(2, math.floor(math.sqrt(x))+1):
    max = 0
    p = 1
    for j in range(10000):
        if i ** p <= x:
            max = i ** p
            p += 1
        else:
            break
    if max > ans:
        ans = max
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
m = 1
for i in range(2, x):
    p = 2
    while pow(i, p) <= x:
        if m <= pow(i, p):
            m = pow(i, p)
        p += 1
    
        
print(m)

Submission status: Accepted

Solution code:
X = int(input())
beki = [1]
for i in range(2, X):
    c = 2
    while True:
        if i**c > X:
            break
        beki.append(i**c)
        c += 1
        
print(max(beki))

Submission status: Accepted

Solution code:
x = int(input())
out = 1
for i in range(2,33,1):
    for j in range(2,10,1):
        num = i**j
        if x >= num:
            out = max(out, num)
print(out)

Submission status: Accepted

Solution code:
import sys

n = int(input())

res = 0
if n == 1:
    print(1)
    sys.exit()
for i in reversed(range(2, n+1)):
    cnt = 2
    while True:
        if pow(i, cnt) > n:
            break
        else:
            if res < pow(i, cnt):
                res = pow(i, cnt)
        cnt += 1
print(res)

Submission status: Accepted

Solution code:
n = int(input())
ans = 1

for i in range(1, n):
  for j in range(2, n):
    if i ** j > n:
      break
    if i**j > ans:
      ans = i**j

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
l = []

for i in range(1,32):
    for j in range(2,9):
        l.append(i ** j)
        
l = list(sorted(set(l)))
c = 1        
for i in range(len(l)):
    if l[i] <= x and x< l[i+1]:
        c = l[i]
        break
print(c)

Submission status: Accepted

Solution code:
x = int(input())
flag = False
while True:
    if flag:
        break
    for i in range(x):
        if flag:
            break
        for j in range(x):
            if i ** j == x:
                print(i ** j)
                flag = True
                break
            if i ** j > x:
                break
    x -= 1

Submission status: Accepted

Solution code:
import math

x = int(input())

max = 1
for i in range(2, int(math.sqrt(x)) + 1):
  for j in range(x):
    if i ** j > x:
      break
    else:
      if i ** j > max:
        max = i ** j

print(max)

Submission status: Accepted

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

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

    print(ans)


if __name__ == '__main__':
    main()