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:
import math

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

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

    print(ans)

main()

Submission status: Accepted

Solution code:
X = int(input())

max_ = 1

for i in range(2,X):
  power=1
  while i**(power+1)<=X:
    power+=1
    
  if power==1:
    break
    
  if i**power>max_:
    #print(i)
    #print(power)
    max_=i**power
    
print(max_)

Submission status: Accepted

Solution code:
X=int(input())
List=[1]
for i in range(2,32):
  j=2
  while True:
    if i**j<=1000:
      List.append(i**j)
      j+=1
    else:
      break
x=1
for i in range(len(List)):
  if List[i]<=X:
    x=max(x,List[i])
print(x)

Submission status: Accepted

Solution code:
n = int(input())
r = 1
for i in range(2, 11):
    if r < int(n ** (1 / i)) ** i:
        r = int(n ** (1 / i)) ** i
    elif n == 1000:
        r = n
print(r)

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
for b in range(1,32):
    for p in range(2,9):
        if b**p <= X and ans<=b**p:
            ans = b**p
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for j in range(1,N):
    for k in range(2,100):
        if N >= j ** k:
            if ans < j ** k:
                ans = j ** k
 
if N == 1:
    print(1)
else:
    print(ans)

Submission status: Accepted

Solution code:
X = int(input())
l = list()
S = set()
for a in range(32):
    l.append(a)
    for b in range(2, 11):
        if l[a]**b<=X:
            S.add(l[a]**b)
print(max(S))

Submission status: Accepted

Solution code:
import math
x=int(input())
num=math.floor(x/2)
flag=0
max=1
for i in range(num):
    flag=0
    for j in range(num):
        if i==1:
            break
        if i**j<=x:
            if i**j>=max:
                max=i**j
        else:
            flag=1
            break
print(max)

Submission status: Accepted

Solution code:
x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:
          c=max(c,b**p)
        else:break
print(c)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for b in range(1, x):
    for p in range(2, x):
        if b**p <= x:
            ans = max(ans, b**p)
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
set_x = set(n**e for n in range(32) for e in range(2, 11) if n**e <= x)
ans = max(set_x)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
x = int(input())
ans = []
for i in range(2,11):
  ans.append(int(math.pow(x,(1/i)))**i)
if x == 1000:
  print(1000)
else:
  print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for i in range(int(x ** 0.5) + 1):
    for j in range(int(x ** 0.5) + 1):
        if i ** j <= x:
            ans = max(ans, i ** j)
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for b in range(2, x+1):
    if b ** 2 > x:
        continue

    p = 2
    while b ** (p+1) <= x:
        p += 1
    ans = max(ans, b ** p)

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for b in range(x):
    for p in range(2, x):
        if b**p <= x:
            ans = max(ans, b**p)
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
c = [1]
for i in range(2,32):
    num = 2
    while i**num <= x:
        c.append(i**num)
        num+=1
print(max(c))

Submission status: Accepted

Solution code:
import math

x=int(input())
ans=1
sa=x-ans
if sa>=3:
    a=math.floor(math.sqrt(x))
    for i in range(2,a+1):
        p=2
        while i**p<=x:
            if x-(i**p)<sa:
                sa=x-(i**p)
                ans=i**p
            p+=1
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
m = 0
for i in range(1,1000):
    for j in range(2,11):
        if x >= i**j:
            m = max(m, i**j)
print(m)

Submission status: Accepted

Solution code:
x = int(input())
maxi = 0
for i in range(2,x+1):
  p = 2
  while True:
    if i ** p <= x:
      if maxi < i ** p:
        maxi = i ** p
      p += 1
    else:
      break
if x <= 3:
  print(1)
else:
  print(maxi)

Submission status: Accepted

Solution code:
X = int(input())

ans = 1
for b in range(2, X+1):
    a = X
    c = 0
    while a >= b:
        c += 1
        a = a // b
    if c >= 2:
        ans = max(ans, b**c)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
result = 1
for b in range(1, x):
    for p in range(2, x):
        if b**p <= x:
            result = max(result, b**p)
        else:
            break
print(result)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for b in range(1,32):
  for p in range(2,10):
    if b**p >x:
      break
    elif b**p > ans:
      ans = b**p
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
S = set(n**e for n in range(32) for e in range(2,11) if n**e<=X)
print(max(S))

Submission status: Accepted

Solution code:
X = int(input())

ans = 0
for i in range(1001):
    for e in range(2, 10):
        if i ** e > X:
            continue
        ans = max(ans, i ** e)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

beki_list = []
for i in range(1, 32): # ベース
    for j in range(2, 10): # ベースにべき乗する数
        beki = i**j
        if beki <= 1000:
            beki_list.append(beki)


# 存在する1000以下のべき乗数を、大きい順に比較していく
beki_list.sort(reverse=True)

for beki in beki_list:
    if beki <= x:
        print(beki)
        exit()

Submission status: Accepted

Solution code:
x = int(input())

## まず、1000以下のべき乗数のリストを作る
# print(2**9) -> 512
beki_list = []
for i in range(1, 101): # ベース
    for j in range(2, 10): # ベースにべき乗する数
        beki = i**j
        if beki <= 1000:
            beki_list.append(beki)

# 存在する1000以下のべき乗数を、大きい順に比較していく
beki_list.sort(reverse=True)

for beki in beki_list:
    if beki <= x:
        print(beki)
        exit()

Submission status: Accepted

Solution code:
X = int(input())

res = 0
if X <= 3:
    res = 1
else:
    for i in range(2,X):
        c = 2
        while 1:
            a = i**c
            if a <= X:
                if res < a:
                    res = a
                c += 1
            else:
                break
print(res)

Submission status: Accepted

Solution code:
X = int(input())

max_num = 1
for b in range(2, 32):
    num = b
    for p in range(2, 11):
        num *= b
        if num <= X and num >= max_num:
            max_num = num

print(max_num)

Submission status: Accepted

Solution code:
x = int(input())
max_num = 0
for b in range(1, 33):
    for p in range(2, 33):
        if b**p > x:
            continue
        max_num = max(max_num, b**p)
print(max_num)

Submission status: Accepted

Solution code:
x = int(input())
if x == 1:
    print(1)
    exit()
li = list(range(2,x+1))
ans = [1]
n = 2
while li[0]**n < x:
    for i in range(x-1):
        if li[i]**n > x:
            ans.append(li[i-1]**n)
            break
    n += 1
print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())
def createC(x, z):
  tmp = []
  for y in range(x):
    p = pow(y+1, z)
    if p <= x:
      tmp.append(p)
    else:
      return tmp

z = 2
max_c = 1
while True:
  if x == 1:
    break
  c_tmp = createC(x, z)
  if len(c_tmp) != 1:
    s = sorted(c_tmp)
    if max_c < s[-1]:
      max_c = s[-1]
    z += 1
  else:
    break
print(max_c)

Submission status: Accepted

Solution code:
x = int(input())
def createC(x, z):
  tmp = []
  for y in range(x):
    p = pow(y+1, z)
    if p <= x:
      tmp.append(p)
    else:
      return tmp

c = []
z = 2
max_c = 1
while True:
  if x == 1:
    break
  c_tmp = createC(x, z)
  if len(c_tmp) != 1:
    s = sorted(c_tmp)
    if max_c < s[-1]:
      max_c = s[-1]
    z += 1
  else:
    break
print(max_c)

Submission status: Accepted

Solution code:
x=int(input())
a=[]
for i in range(1,1000):
	for j in range(2,10):
		a.append(i**j)
a.sort()
import bisect
k=bisect.bisect_right(a,x)
print(a[k-1])

Submission status: Accepted

Solution code:
# ABC097-B
ans_list = [1]
for i in range(2, 10):
    ans_list.append(2 ** i)
for i in range(2, 7):
    ans_list.append(3 ** i)
for i in range(2, 5):
    ans_list.append(5 ** i)    
for i in range(2, 4):
    ans_list.append(6 ** i)
    ans_list.append(7 ** i)
    ans_list.append(10 ** i)
num = [11,12, 13, 14, 15, 17, 18, 19, 20, 21, 22,  23,24, 25, 26, 27, 28,  29, 30,  31]
for i in num:
    ans_list.append(i ** 2)
X = int(input())
for i in range(X, 0, -1):
    if i in ans_list:
        ans = i
        break
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

max_powered = 1

for num in range(2, x):
    cand = num * num
    
    while cand <= x:
        if max_powered < cand:
            max_powered = cand
        cand *= num

print(max_powered)

Submission status: Accepted

Solution code:
import bisect

N = int(input())

lst = [1]
for i in range(2, 31+1):
  var = i ** 2
  while True:
    if var <= 1000:
      lst.append(var)
      var *= i
    else:
      break

lst = list(set(lst)) 
lst.sort()
#print(lst)
idx = bisect.bisect_right(lst, N)
#print(idx)
print(lst[idx-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = []
for j in range(2,11):
    l = [i**j for i in range(1,32) if i**j <= n]
    ans = ans + l
print(max(ans))

Submission status: Accepted

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

s = set([1])
for b in range(2, int(math.sqrt(N))+1):
    p = 2
    while b**p <= N:
        s.add(b**p)
        p += 1

ans = max(s)
print(ans)

Submission status: Accepted

Solution code:
l=sorted([i**j for i in range(1,33)for j in range(2,10)])
n=int(input())
for i,m in enumerate(l):
	if m>n:
		print(l[i-1])
		exit()

Submission status: Accepted

Solution code:
x=int(input())

ans=1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
exp = set()
for i in range(8):
    num = 1
    while True:
        temp = num ** (i + 2)
        if temp <= x:
            exp |= {temp,}
            num += 1
        else:
            break
print(max(exp))

Submission status: Accepted

Solution code:
#%%
X = int(input())
l = []

a = round(1000*0.5)

for i in range(2,a):
    j = 2
    b = 0
    while b <= 1000:
        b = i ** j
        if b <= 1000:
            l.append(b)
        j += 1

l.append(1)
l.sort()

ans_list =[]
for i in range(len(l)):
    if l[i] <= X:
        ans_list.append(l[i])
print(max(ans_list))

Submission status: Accepted

Solution code:
from math import ceil,sqrt

X = int(input())

ans = 0
p = ceil(sqrt(X))+1
for i in range(p):
    for j in range(p):
        if i**j <= X:
            ans = max(ans,i**j)

print(ans)

Submission status: Accepted

Solution code:

x = int(input())

res = 0
for b in range(1, x + 1):
    for p in range(2,100):
        y = pow(b, p)
        if y > x:
            break
        res = max(y, res)
        if res == x:
            break

print(res)

Submission status: Accepted

Solution code:
import math

x = int(input())
#a = int(input())
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b = list(map(int,input().split(" ")))
#a,b,c = list(input().split())
#string = input()
ans = 0
for i in range(2,x+1):
  tmp = 0
  j = 2
  tmp = i ** j
  while(tmp <= x):
    if ans <= i ** j:
      ans = i ** j
    j += 1
    tmp = i ** j
if ans == 0:
  print("1")
  quit()
print(ans)

Submission status: Accepted

Solution code:
#ABC 97, B - exponential

def compute():
    x = int(input())
    if x == 1:
        print(1)
    else:
        beki = []
        for b in range(31, 1, -1):
            for p in range(9, 1, -1):
                beki.append(b**p)
        for y in sorted(beki)[::-1]:
            if y <= x:
                print(y)
                return
compute()

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
  
i = 1
while i * i <= n:
  i += 1
  j = 1
  while j * i <= n:
    j *= i
  
  ans = max(ans, j)
  
print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_left

cand = [1]
for b in range(2, 32):
    for p in range(2, 10):
        cand.append(b ** p)
cand.sort()

X = int(input())
i = bisect_left(cand, X + 1)
print(cand[i-1])

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for b in range(2, 32):
    for p in range(1, 10):
        if b ** (p + 1) > X:
            break
    if p == 1:
        continue
    ans = max(ans, b ** p)
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
ans=[]
c=0
for i in range(1,x+2):
    for j in range(2,x+3):
        c=i**j
        if c>x:
            break
        elif ans.count(c)==0:
            ans.append(c)
print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = []
for b in range(2,40):
    for p in range(2, 11):
        v = pow(b, p)
        if v <= x:
            ans.append(v)
        else:
            break
if len(ans) > 0:
    print(max(ans))
else:
    print(1)

Submission status: Accepted

Solution code:
X = int(input())
ansMax = 0
for i in range(1, X + 1):
    for j in range(2, X + 2):
        tmp = i ** j
        if X >= tmp:
            ansMax = max(ansMax, tmp)
        else:
            break

print(ansMax)

Submission status: Accepted

Solution code:
X=int(input())
ans=1
for b in range(1,32):
  for p in range(2,10):
      a=b**p
      if a>X:
        break
      if a>ans:
        ans=a
print(ans)

Submission status: Accepted

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

for i in range(2,X+1):
    p = 2
    while (X >= i ** p):
        ans = max(ans, i ** p)
        p += 1
        # print('i=',i)
        # print('p=',p)
        # print(i**p)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
num = 2
idx = 1
nums = [1]
while True:
  if num**idx > N:
    if idx == 2 or N in range(1, 5):
      break
    else:
      num += 1
      idx = 0
      continue
  else:
    nums.append(num**idx)
    idx += 1
nums.sort(key=lambda x:-x)
print(nums[0])

Submission status: Accepted

Solution code:
a = int(input())
b = int(a ** 0.5)
c = 0
d = 1
for i in range(2, b + 1):
    c = i
    while True:
        if c <= a:
            c = c * i
        else:
            c = c // i
            d = max(d, c)
            break
print(d)

Submission status: Accepted

Solution code:
X = int(input())

nums = []
for p in range(2, 10):
    for b in range(1, 33):
        if b ** p > X:
            break
        if b ** p <= X:
            nums.append(b ** p)

print(max(nums))

Submission status: Accepted

Solution code:
x=int(input())
lst=[]
for b in range(1,32):
    for q in range(2,11):
        if b**q <=x:
            lst.append(b**q)
        elif b**q>x:
            break
print(max(lst))

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#A
def A():
    a, b, c, d = LI()
    x = abs(a - b)
    y = abs(b - c)
    z = abs(a - c)
    if (x <= d and y <= d) or z <= d:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    X = II()
    x = [False] * (10 ** 3 + 1)
    x[1] = True
    for i in range(2, int(10 ** 1.5) + 1):
        k = i*i
        while X >= k:
            x[k] = True
            k *= i
    for i in range(X, -1, -1):
        if x[i]:
            print(i)
            return
    return

#C
def C():
    s = stdin.readline().rstrip()
    K = II() - 1
    ans = []
    for i in range(len(s)):
        for k in range(K+1):
            b = s[i:i + k + 1]
            ans.append(b)
    ans = list(set(ans))
    ans.sort()
    print(ans[K])
    return

#D
def D():
    n, m = LI()
    p = LI_()
    xy = LIR_(m)
    size = [1 for _ in range(n)]
    height = [1 for _ in range(n)]
    par = [i for i in range(n)]
    def find(x):
        if par[x] == x:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def union(x, y):
        s1 = find(x)
        s2 = find(y)
        if s1 != s2:
            if height[s1] < height[s2]:
                par[s1] = s2
                size[s2] += size[s1]
                size[s1] = 0
            else:
                par[s2] = s1
                size[s1] += size[s2]
                size[s2] = 0
                if height[s1] == height[s2]:
                    height[s1] += 1

    for x,y in xy:
        union(x, y)
    ans = 0
    for i in range(n):
        if find(p[i]) == find(i):
            ans += 1
    
    print(ans)
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Accepted

Solution code:
x = int(input())

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

def f(b, p):
  return b ** p

ans = []

for b in range(2, x):
  for p in range(2, x):
    temp = f(b, p)
    if temp <= x:
      ans.append(temp)
    else:
      break

print(max(ans))

Submission status: Accepted

Solution code:
x=int(input())
m=1
for b in range(2,33):
    for p in range(2,10):
        if b**p<=x:m=max(b**p,m)
print(m)

Submission status: Accepted

Solution code:
X = int(input())
result = 1
for i in range(2,X):
    if i**2 > X:
        break
    j = 2
    while True:
        if i**j > X:
            break
        j += 1
    if i**(j-1) > result:
        result = i**(j-1)
print(result)

Submission status: Accepted

Solution code:
x = int(input())
a = [1]

for i in range(2,32):
    for j in range(2,11):
        if i ** j > x:
            break
        a.append(i ** j)
print(max(a))

Submission status: Accepted

Solution code:
x = int(input())

max = 0
for i in range(int(x**0.5) + 1):
    for j in range(int(x**0.5) + 1):
        temp = i ** j
        if max < temp <= x:
            max = temp

print(max)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for b in range(2, 32):
    p = 2
    while b ** p <= x:
        ans = max(ans, b ** p)
        p += 1
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
li = []
for i in range(1,32):
    for j in range(2,32):
        if i**j<=1000:
            li.append(i**j)
li = list(set(li))
li.sort()
for k in range(len(li)-1,-1,-1):
    if li[k]<=x:
        print(li[k])
        break

Submission status: Accepted

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

Submission status: Accepted

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

X = int(input())

for i in range(X, 0, -1):
    for j in range(math.floor(math.sqrt(X)), 0, -1):
        for k in range(10):
            if pow(j, k) == i:
                print(pow(j, k))
                exit()

Submission status: Accepted

Solution code:
n = int(input())

ans = 1
for i in range(n):
    for j in range(2, 11):
        k = i ** j
        if k <= n:
            ans = max(ans, k)
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for b in range(1,N+1):
    for p in range(2,100):
        if b**p>N:
            break
        ans = max(ans,b**p)
print(ans)

Submission status: Accepted

Solution code:
import sys
x = int(input())
for i in range(x,0,-1):
  for j in range(2,10):
    if round((i**(1/j)),5)%1 == 0:
      print(i)
      sys.exit()

Submission status: Accepted

Solution code:
a = int(input())
for i in range(a, 0, -1):
    for j in range(int(i**0.5), 1, -1):
        b = i
        while True:
            if b % j == 0:
                b = b // j
                if b == 1:
                    print(i)
                    exit()
            else:
                break
print(1)

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
k = 2
while 2 ** k <= x:
    # print("k =", k)
    i = 1
    while i ** k <= x:
        # print("i =", i)
        r = i ** k
        # print("r =", r)
        ans = max(ans, r)
        i += 1
    k += 1
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
m = 1
for i in range(2,(x+1)//2):
  tmp = 0
  k = 0
  while tmp <= x:
    m = max(m,tmp)
    tmp = i**k
    k+=1
print(m)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for b in range(2, int(x / 2)):
    p = 2
    sub = 1
    while b**p <= x:
        sub = b**p
        p += 1
    ans = max(ans, sub)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for b in range(1, x):
    for p in range(2, x):
        e = b ** p
        if ans < e and e <= x:
            ans = e
        if e > x:
            break
if x == 1:
    ans = 1
print(ans)

Submission status: Accepted

Solution code:
import math
n=int(input())
if n<=3:
    print(1)
    exit()
rn=int(math.sqrt(n))
s=set()
for i in range(2,rn+1):
    tmp=i
    while tmp<n:
        tmp*=i
        if tmp<=n:
            s.add(tmp)
print(max(s))

Submission status: Accepted

Solution code:
X = int(input())
max = 1
b = 2
while b*b <= X:
	m = b*b
	while m <= X:
		if max < m:
			max = m
		m *= b
	b += 1
print(max)

Submission status: Accepted

Solution code:
N = int(input())
ans = set()
for i in range(1,N+1):
    for j in range(2,10):
        if i**j <= N:
            ans.add(i**j)
print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())

ans = 1

for i in range(2,x+1):
    j = 2
    if i**j>x:
        break
    while i**j<=x:
        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):
    j = 2
    while i**j<=x:
        ans.append(i**j)
        j+=1
ans.sort()
print(ans[-1])

Submission status: Accepted

Solution code:
x = int(input())
c = [1]
for i in range(2,32):
	num = 2
	while i**num<=x:
		c.append(i**num)
		num+=1
print(max(c))

Submission status: Accepted

Solution code:
x=int(input())

ans=1
for b in range(2,int(x**(1/2))+1):
    p=2
    check=b**p

    while check<=x:
        ans=max(ans,check)
        p+=1
        check=b**p
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
if X == 1:
    print(1)
    exit()

max_x = 1
for i in range(2, 32):
    p = 2
    while i ** p <= X:
        if i ** p > max_x:
            max_x = i ** p
        p += 1
print(max_x)

Submission status: Accepted

Solution code:
import sys
import math

def input():
    return sys.stdin.readline().rstrip()

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

    l = { i ** j for i in range(1, int(math.sqrt(x))+1) for j in range(2, 10) if i ** j <= x }

    print(max(l))

Submission status: Accepted

Solution code:
import sys
import math

def input():
    return sys.stdin.readline().rstrip()

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

    l = { i ** j for i in range(1, int(math.sqrt(x))+1) for j in range(2, 10) if i ** j <= x}

    print(max(l))

Submission status: Accepted

Solution code:
import sys
import math

def input():
    return sys.stdin.readline().rstrip()

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

    l = { i ** j for i in range(1, int(math.sqrt(x))+1) for j in range(2, 11) if i ** j <= x}

    print(max(l))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    x = int(input())
    l = set()
    l.add(1)

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

    for i in range(1000):
        for j in range(2, 1000):
            if i ** j > 1000:
                break
            l.add(i ** j)

    x = set(range(x + 1, 1001))
    l = l - x
    print(max(l))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

exps = [1]
for i in range(1, X+1):
    for j in range(2, X+1):
        e = i**j
        if e <= X:
            exps.append(e)
        else:
            break

exps.sort(reverse=True)
print(exps[0])

Submission status: Accepted

Solution code:
x=int(input())

nums=[1]

for b in range(2,x):
    p=2
    while b**p<=x:
        nums.append(b**p)
        p+=1
print(max(nums))

Submission status: Accepted

Solution code:
x=int(input())
nums=[1]

for b in range(2,x):
    p=2
    while b**p<=x:
        nums.append(b**p)
        p+=1
print(max(nums))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
x=int(input())
beki_list = []
for i in range(1,int(math.sqrt(1000))+1):
    for j in range(2,11):
        if i**j<=x:
            beki_list.append(i**j)

print(max(beki_list))

Submission status: Accepted

Solution code:
x = int(input())

if x == 1:
    print(1)
else:
    answer = 0
    for i in range(2, x):
        if x < i ** 2:
            break
        
        j = 2
        while True:
            if i ** j > x:
                break
            if i ** j > answer:
                answer = i ** j
            j += 1
    print(answer)

Submission status: Accepted

Solution code:
n = int(input())
ciel = int(n**(1/2))
maxs=[1]
for a in range(2,ciel+2):
    b=1
    ans = 0
    while ans <= n:
        ans = a**b
        b+=1
    maxs.append(ans/a)
print(int(max(maxs)))

Submission status: Accepted

Solution code:
x=int(input())
v=[]
for j in range(2,11):
    for i in range(1,32):
        if i**j<=x and (i+1)**j>x:
            v.append(i**j)
            break
print(max(v))

Submission status: Accepted

Solution code:
x=int(input())
v=[]
for i in range(1,32):
    for j in range(2,1000):
        if i**j<=x and (i+1)**j>x:
            v.append(i**j)
print(max(v))

Submission status: Accepted

Solution code:
X = int(input())

v = int(X ** 0.5)
m = X
ans = 1

for b in range(2, v + 1):
    p = 2
    j = b ** p
    while j <= X:
        if j <= X and X - j <= m:
            m = X - j
            ans = j
        p += 1
        j = b ** p      
            
print(ans)

Submission status: Accepted

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

exlist = [1]
for i in range(2, math.floor(x**0.5)+1):
    tmp = i
    while tmp <= x:
        exlist.append(tmp)
        tmp *= i
print(max(exlist))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	X = int(input())
	
	ans = []
	for i in range(1, 1000):
		for j in range(2, 1000):
			tmp = i**j
			if tmp > X:
				break
			ans.append(tmp)
			
	ans.sort()
	print(ans[-1])
			
	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
if x==1:
  print(1)
else:
  beki=[]
  for b in range(1,x+1):
    for p in range(2,x+1):
      if b**p<=x:
        beki.append(b**p)
      else:
        break
  print(max(beki))

Submission status: Accepted

Solution code:
X = int(input())
m = 1
for i in range(2,X):
    lis = [i**j for j in range(2,11) if i**j <= X]
    if len(lis) != 0:
        m = max(max(lis),m)
print(int(m))

Submission status: Accepted

Solution code:
x = int(input())

max_num = 0
for i in range(x):
	if x == 1:
		max_num = 1
		break
	j = 1

	while (i+2) ** j <= x:
		if max_num < (i+2) ** j:
			max_num = (i+2) ** j
		j += 1
	if j == 2:
		break
print(max_num)

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

X = n()
max_beki = 1

for b in range(2, X):
    num = b * b
    while num <= X:
        if num > max_beki:
            max_beki = num
        num *= b
print(max_beki)

Submission status: Accepted

Solution code:

X = int(input())
lis = [1]
blflag = False

for i in range(X):

    i += 2

    cnt = 2
    while True:

        if i ** cnt <= X:
            lis.append( i ** cnt )

        elif cnt == 2:
            blflag = True
            break

        else:
            break

        cnt += 1

    if blflag:
        break

lis.sort()

print (lis[-1])

Submission status: Accepted

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