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:
def main():
    x = int(input())
    limit = int(x**0.5)+2
    ans = 0
    for i in range(limit):
        for j in range(2,limit):
            p=i**j
            if p <= x:
                ans = max(ans, p)
            else:
                break
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())

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

res = 1
for i in range(2,32):
    for j in range(2,10):
        x = i**j
        if x > a:
            pass
        else:
            res = max(res,x)
print(res)

Submission status: Accepted

Solution code:
ary = [0] * 1000000
for i in range(1, 1000 + 1):
    for j in range(2, 1000 + 1):
        val = i ** j
        # print(val)
        if val > 1000:
            break
        ary[val] += 1
x = int(input())
for i in range(x + 1):
    index = x - i
    if ary[index] > 0:
        break
print(index)

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
for i in range(1,500):
  for j in range(2,10):
    if i**j<=X:
      ans = max([ans, i**j])
    else:
      break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
if N <= 3:
    print(N)
    exit(0)
for i in range(2, 33):
    for j in range(2, 11):
        t = i ** j
        if t <= N:
            ans = max(ans, t)
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

max_num = 1

for bosuu in range(1, 50):
    for sisuu in range(2, 11):
        num = bosuu ** sisuu
        
        if (num <= X):
            max_num = max(max_num, num)
        else:
            break

print(max_num)

Submission status: Accepted

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

def IsBekijo(x):
    if x == 1:
        return True
    for i in range(2,math.ceil(math.sqrt(x)) + 1):
        if x % i == 0:
            d = x // i
            while d != 1:
                if d % i == 0:
                    d //=  i
                else:
                    break
            if d == 1:
                return True
    return False

for i in range(X,0, -1):
    if IsBekijo(i):
        print(i)
        break

Submission status: Accepted

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

def IsBekijo(x):
    for i in range(2,math.ceil(math.sqrt(x)) + 1):
        if x % i == 0:
            d = x // i
            while d != 1:
                if d % i == 0:
                    d //=  i
                else:
                    break
            if d == 1:
                return True
    return False



for i in range(X,0, -1):
    if IsBekijo(i):
        print(i)
        exit()
print(1)

Submission status: Accepted

Solution code:
x = int(input())

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

ans = 1
for b in range(2, 1000 + 1):
    for p in range(2, 10+1):
        bp = b**p
        if bp <= x:
            ans = max(ans, bp)

print(ans)

Submission status: Accepted

Solution code:
import math
x=int(input())
l=[1]
for i in range(2,int(math.sqrt(x))+1):
  p=i
  while 1:
    p*=i
    if p<=x:
      l.append(p)
    else:
      break
l.sort()
print(l[-1])

Submission status: Accepted

Solution code:
x = int(input())
if x == 1:
    print(1)
elif x == 1000:
    print(1000)
else:
    print(int(max(int((x ** (1 / i))) ** i for i in range(2, x + 1))))

Submission status: Accepted

Solution code:
x = int(input())

lst = []
for i in range(1,101):
    for j in range(2,10):
       lst.append(i**j)
lst.sort(reverse=True)

for n in lst:
    if n <= x:
        print(n)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
List = [1]
a =0
for i in range(2,35):
  for j in range(2,11):
    a = i**j
    if a <= 1000:
      List.append(i**j)
    else:
      break
List.sort()
k = 0
for i in range(len(List)):
  if List[i] > X:
    k = i-1
    break
  elif List[i] == X:
    k = i
    break
print(List[k])

Submission status: Accepted

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

for i in reversed(range(1, x + 1)):
    for j in range(2, 101):
        for k in range(2, 101):
            number = j ** k
            if number == i:
                print(i)
                exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
maxi = 1
for i in range(1,32):
  for j in range(2,10):
    l = i**j
    if l<=n:
    	maxi = max(maxi, l)
print(maxi)

Submission status: Accepted

Solution code:
n = int(open(0).read().rstrip())

exes = {1}

for i in range(2,1001):
    if not i in exes:
        to_add = i
        while to_add * i <= 1000:
            to_add *= i
            exes.add(to_add)

print(max(filter(lambda x:x<=n, exes)))

Submission status: Accepted

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

print(a)

Submission status: Accepted

Solution code:
def f(N):
  for i in range(int(N**0.5)+1):
    for j in range(N):
    	if (e := pow(i, j)) <= N:
          yield e
n = int(input())
print(max(f(n)))

Submission status: Accepted

Solution code:
import math

X = int(input())

for k in range(X,0,-1):
    for i in range(2,int(math.sqrt(k))+2,1):
        tmp = i
        tmp = tmp*i
        while tmp <= k:
            if tmp ==k:
                print(k)
                exit()
            tmp = tmp*i
print(1)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
tmp = 1
for i in range(1, int(x**0.5)+1):
    for j in range(2, x):
      tmp = pow(i, j)
      if tmp > x:
          tmp = pow(i, j-1)
          #print(tmp, i, j)
          break

    ans = max(tmp, ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

ans = 0

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

Submission status: Accepted

Solution code:
X = int(input())
final = 0
for i in range(40):
    for j in range(2,11):
        if i**j > X:
            final = max(ans,final)
            break
        ans = i**j
print(final)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    X = int(input())
    ans = []
    for p in range(2, 10):
        for b in range(1, 35):
            if b**p <= X:
                ans.append(b**p)
    print(max(ans))
resolve()

Submission status: Accepted

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

X = int(input())

ret = 0
for i in range(1, 1001):
    for j in range(2, 20):
        if i**j <= X:
            ret = max(i**j, ret)

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

for b in range(1,x+1):
  for q in range(2,x+2):
    a = b**q
    if a <=x:
      c.append(a)
    else:
      break

C = set(c)
print(max(C))

Submission status: Accepted

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

for b in range(1,x):
  for q in range(2,x):
    if b**q <=x:
      c = max(c,b**q)
    else:
      break
print(c)

Submission status: Accepted

Solution code:
import math
x = int(input())
ans = 0
mx = 0
for b in range(1, int(math.sqrt(x))+1) :
    if b == 1 :
        mx = 1
        continue
    p = 1
    while b ** p <= x :
        mx = max(b**p, mx)
        p += 1
print(mx)

Submission status: Accepted

Solution code:
X = int(input())
l=[]
for i in range(1,101):
    for j in range(2,11):
        if i**j > 1000:
            break
        else:
            l.append(i**j)
for k in range(X):
    if X - k in l:
        print(X-k)
        break

Submission status: Accepted

Solution code:
X = int(input())

lst = []
for i in range(1,101):
    for j in range(2,11):
        if i**j > 1000:
            break
        else:
            lst.append(i**j)

for k in range(X):
    if X - k in lst:
        print(X-k)
        break

Submission status: Accepted

Solution code:
X = int(input())
m = 1
for b in range(1, int(X**0.5)+1):
    for p in range(2, X):
        if b**p <= X:
            m = max(m, b**p)
print(m)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    ans = 1
    for b in range(1,X+1):
        for p in range(2,10):
            a = b**p
            if a > X:
                break
            elif ans < a and a <= X:
                ans = a
            # print(b,p,a,ans)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for b in range(1,X):
  for p in range(2,10):
    if b**p<=X:
      ans = max(ans,b**p)
      
print(ans)

Submission status: Accepted

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

X = int(input())

ans = 1
b = 1
p = 2

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

print(ans)

Submission status: Accepted

Solution code:
def solve():
    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)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
if x == 1:
    ans = 1
else:
    for i in range(2, int(x**0.5)+1):
        j = 2
        while True:
            if i**j > x:
                break
            else:
                ans = max(i**j, ans)
                j += 1

print(ans)

Submission status: Accepted

Solution code:
X = int(input())

# Xは1000以下なので、pは2**10=1024より10まで探索すれば十分
# 同様にbは40程度まで考えれば十分
max_ex = 1
for p in range(2, 10):
  for b in range(1, 40):
    if max_ex < b**p <= X:
      max_ex = b**p
      
print(max_ex)

Submission status: Accepted

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

for b in range(1,X):
  for p in range(2,10):
    if b**p<=X:
      ans = max(ans,b**p)
      
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

answer = 1
for i in range(n//2+1):
  for j in range(2,n//2+1):
    check = i**j
    if check <= n:
      if (answer < check):
        answer = i**j
    else :
      break

print(answer)

Submission status: Accepted

Solution code:
import math
X = int(input())
res = 1
for i in range(2, int(math.sqrt(X)) + 1):
    j = 2
    while i ** j <= X:
        j += 1
    res = max(res, i ** (j - 1))
print(res)

Submission status: Accepted

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

sq_x = int(x ** 0.5)
ans = 1
for i in range(2, sq_x + 1):
    t = i
    while t <= x:
        ans = max(ans, t)
        t *= i

print(ans)

"""
最初は
p = int(math.log(x, i))
でいけるかと思ったが
math.log(1000,10)のとき 2.999..みたいな値になってしまい，誤差がある
"""

Submission status: Accepted

Solution code:
X = int(input())

beki = [1]
for b in range(2, int(pow(X, 0.5))+1):
    p = 2
    while pow(b, p) <= X:
        beki.append(pow(b, p))
        p += 1
print(max(beki))

Submission status: Accepted

Solution code:
import math
def main():
  x = int(input())
  sum=0
  if x==0 or x==1:
    sum=x
  else:
    for i in range(2,int(math.sqrt(x))+1):
      j=2
      while True:
        if pow(i,j) <= x:
          if pow(i,j) > sum:
            sum=pow(i,j)
        else:
          break
        j+=1
  print(sum)
main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
x = int(input())
ans = 1

n = 2

while x >= 2**n:
    c = 1
    while x >= c**n:
        ans = max(ans, c**n)
        c += 1
    n += 1
print(ans)

Submission status: Accepted

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

X = int(input())
ans = 1

for b in range(2, X+1):
    for i in itertools.count(2):
        bp = b ** i
        # print(bp)
        if bp <= X:
            ans = max(ans, bp)
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
x=int(input())
ans=1
for num in range(2,x+1):
    k=x
    cnt=0
    while k>=num:
        k//=num
        cnt+=1
    if cnt>=2:
        ans=max(ans,pow(num,cnt))
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    x = int(input())
    ans = 1
    for i in range(1, x + 1):
        for j in range(2, 11):
            if i ** j <= x:
                ans = max(ans, i ** j)
            else:
                break
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

a aa c ca c a b a ab a b c

"""

Submission status: Accepted

Solution code:
import math

x = int(input())
ans = [1]
s = int(math.sqrt(x))
if s >= 2:
    for i in range(2,s+1):
        temp = i
        while True:
            temp *= i
            if temp <= x:
                ans.append(temp)
            else:
                break

print(max(ans))

Submission status: Accepted

Solution code:
import math

n = int(input())
ans = [1]
b = int(math.sqrt(n))
if b >= 2:
    for i in range(2,b+1):
        temp = i
        while True:
            temp*=i
            if temp <= n:
                ans.append(temp)
            else:
                break

print(max(ans))

Submission status: Accepted

Solution code:
import math
x=int(input())
ans=0
if x<=3:
    print(1)
    exit()
for i in range(2,int(math.sqrt(x)//1)+1):
    j=2
    tmp=i**j
    while tmp<x:
        tmp=i**j
        j+=1
        if tmp<=x and tmp>ans:
            ans=tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def solve(x):
    if x == 1:
        return 1
    f = 2
    l = [1]
    while f * f <= x:
        d = f
        while d <= x:
            l.append(d)
            d *= f
        f += 1
    return max(l)



def main():
    X = int(input())
    print(solve(X))
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

res = 1
for i in range(X):
    for p in range(2, X):
        if i ** p <= X:
            res = max(res, i ** p)
        else:
            break
print(res)

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
for i in range(1,X+1):
    for j in range(2,11):
        tmp = i**j
        if ans < tmp <= X:
            ans = tmp
print(ans)

Submission status: Accepted

Solution code:
X=int(input())
ans=0
for i in range(1,X+1):
    for j in range(2,11):
        tmp=i**j
        if ans<tmp<=X:
            ans=tmp
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
if N == 1:
    print(1)
    sys.exit()

for i in range(N,-1,-1):
    for j in range(1,int(N**0.5)+1):
        for k in range(2,11):
            if j**k == i:
                print(i)
                sys.exit()

Submission status: Accepted

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

if not ( 1 <= X <= 1000 ):
    sys.exit()

result = 1
for I in range(1,32):
    for J in range(2,10):
        if I ** J <= X and result <= I ** J:
            result = I ** J

print(result)

Submission status: Accepted

Solution code:
x = int(input())
if x == 1:
  print("1")
  exit()
  
ans = 0
for b in range(2,int(x**(1/2)+1)):
  for p in range(2,1000):
    tmp = pow(b,p)
    if tmp<=x:
      ans = max(ans,pow(b,p))
    else:
      break
      
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

if x <= 3:
  print(x)
  exit()

ans = 0
for i in range(2, int(x**0.5)+1):
  s = 0
  t = 1
  while i**t <= x:
    s = i**t
    t += 1
  ans = max(ans, s)
print(ans)

Submission status: Accepted

Solution code:
X=int(input())

M=1
for b in range(2,X+1):
    if b*b<=X:
        a=b*b
        while a*b<=X:
            a*=b
        M=max(M,a)

print(M)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

if x <= 3:
  print(x)
  exit()

ans = 0
for i in range(2, int(x**0.5)+1):
  s = 0
  t = 1
  while i**t <= x:
    s = i**t
    t += 1
  ans = max(ans, s)
print(ans)

Submission status: Accepted

Solution code:
X=int(input())
s=set(i**j for i in range(40) for j in range(2,10) if i**j<=X)
print(max(s))

Submission status: Accepted

Solution code:
X=int(input())
s=set(pow(i,j) for i in range(40) for j in range(2,10) if pow(i,j)<=X)
print(max(s))

Submission status: Accepted

Solution code:
X = int(input())
tab = set([1])
for i in range(1,X+1):
    for j in range(2,X+1):
        if i**j <= X:
            tab.add(i**j)
        else:
            break
print(max([i for i in tab]))

Submission status: Accepted

Solution code:
X = int(input())
tab = set([])
for i in range(1,1000):
    for j in range(2,1000):
        if i**j <= 1000:
            tab.add(i**j)
        else:
            break

print(max([i for i in tab if i <= X]))

Submission status: Accepted

Solution code:
x = int(input())
k = 0

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

print(k)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,math.ceil(math.sqrt(n))):
    for j in range(2,11):
        if i ** j > n and j > 2:
            ans = max(ans,i ** (j-1))
            break

print(ans)

Submission status: Accepted

Solution code:
X = int(input())

ans = 1
for b in range(1, X + 1):
    for p in range(2, 11):
        a = b ** p
        if a <= X and ans < a:
           ans = a

print(ans)

Submission status: Accepted

Solution code:
x=int(input())
ma=1
for i in range(2,x):
  ex=i**2
  for j in range(x):
    if ex*i>x:
      if ex>ma and ex<=x:
        ma=ex
      break
    ex=ex*i
print(ma)

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
for b in range(1, 1001):
    for p in range(2, 1001):
        if b**p <= X:
            if b**p > ans:
                ans = b**p
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
import math as math
n = int(input())
li = [1]
nroot = int(math.sqrt(n))
for i in range(2,nroot+1):
    for j in range(2,100):
        if i**j <= n:
            li.append(i**j)
        else:
            break
print(max(li))

Submission status: Accepted

Solution code:
x = int(input())
if x <= 3:
  print(1)
  exit()
res = 0
for i in range(2, 33):
  for j in range(2, 12):
    a = i ** j
    if a <= x:
      res = max(res, a)
print(res)

Submission status: Accepted

Solution code:
X = int(input())

max_num = 1
for i in range(1, X + 1):
    for j in range(2, X + 1):
        num = i ** j
        if num <= X:
            if num > max_num:
                max_num = num
        else:
            break

print(max_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    X = int(input())
    if X < 4:
        print(1)
        return
    ans = 1
    for b in range(2, int(X ** 0.5) + 2):
        for p in range(11):
            if b ** p > X: break
            ans = max(ans, b ** p)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def resolve():
    X = int(input())
    A = [1]
    for i in range(2, 33):
        for j in range(2, 11):
            tmp = i**j
            if tmp <= X:
                A.append(tmp)
            else:
                break
    print(max(A))


resolve()

Submission status: Accepted

Solution code:
X = int(input())
print(max(set(b**p for b in range(1,100) for p in range(2,10) if b**p<=X)))

Submission status: Accepted

Solution code:
x=int(input())
a=1
for b in range(1,x+1):
    for p in range(2,x+1):
        t=b**p
        if t>x:
            break
        a=max(a,t)
print(a)

Submission status: Accepted

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

for i in range(1000):
    a=x-i
    if a in lst:
        print(a)
        exit()

Submission status: Accepted

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

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())
p=[]
p.append(1)
for i in range(2,1000):
  for j in range(2,10):
    p.append(pow(i,j))
p.sort()
ans=0
for i in range(len(p)):
  if p[i]>X:
    break
  ans=p[i]
print(ans)

Submission status: Accepted

Solution code:
def actual(X):
    pow_nums = [1]

    for i in range(2, 40 + 1):
        for j in range(2, 40 + 1):
            if i ** j <= 1000:
                pow_nums.append(i ** j)

    pow_nums = sorted(set(pow_nums))

    return [pow_num for pow_num in pow_nums if pow_num <= X][-1]


X = int(input())
print(actual(X))

Submission status: Accepted

Solution code:
x = int(input())

expo = [0]*(x+1)
expo[1] = 1

for i in range(2,x+1):
    v = i*i
    while v <= x:
        expo[v] = 1
        v *= i
        
for i in range(x,-1,-1):
    if expo[i]:
        print(i)
        exit()

Submission status: Accepted

Solution code:
n = int(input())
ex = [False]*(n+1)
ex[1] = True
for i in range(2, n+1):
    v = i*i
    if v>n: break
    while(v<=n):
        ex[v]=True
        v*=i
for i in range(1, n+1)[::-1]:
    if ex[i]:
        print(i)
        break

Submission status: Accepted

Solution code:
X = int(input())

beki = []

for i in range(1, 33):
    for j in range(2, 11):
        beki.append(i**j)

for i in range(X):
    if X-i in beki:
        print(X-i)
        exit()

Submission status: Accepted

Solution code:
x = int(input())
l = set([1])
i = 1
while i < x:
    j = 2
    while j < 10:
        if i**j <= x:
            l.add(i**j)
        j += 1
    i += 1

print(max(l))

Submission status: Accepted

Solution code:
x=int(input())

def pow(b,x):
    res=b
    while True:
        if res*b<=x:
            res=res*b
        else:
            break
    return res


ans=1
for i in range(2,x+1):
    if i**2<=x:
        ans=max(ans,pow(i,x))
print(ans)

Submission status: Accepted

Solution code:
x,l=int(input()),[0]*1001;l[1]=1
for i in range(2,int(x**0.5)+1):
  if l[i]==0:j=i*i
  while 1:
    if j>x:break
    else:l[j]=1;j*=i
for i in range(x,-1,-1):
  if l[i]==1:print(i);break

Submission status: Accepted

Solution code:
x,l=int(input()),[0]*1001;l[1]=1
for i in range(2,x+1):
  if l[i]==0:j=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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
for i in range(int(input()),0,-1):
  if l[i]==1:print(i);break

Submission status: Accepted

Solution code:
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

x = readInt()
l = [0]*(x+1)
l[1]=1

for i in range(2,len(l)):
  if l[i]==0:
    j = i*i
    while 1:
      if j>len(l)-1:
        break
      else:
        l[j]=1
        j*=i


for i in range(len(l)-1,-1,-1):
  if l[i]==1:
    print(i)
    break

Submission status: Accepted

Solution code:
x = int(input())

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


def func(p):
    q = p
    while q < x:
        q *= p
        if q == x:
            return q
    if q / p == p:
        return 1
    else:
        return q // p


z = []
a = 2

while a <= x:
    z.append(func(a))
    a += 1

print(max(z))

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())
A = []
k=20
for i in range(1,int(X**0.5)+1):
    for j in range(k):
        if i**j<=X:
            A.append(i**j)
        elif i++j > X:
            k = j+1
            break
print(max(A))

Submission status: Accepted

Solution code:
def is_prime(n):
    if n <= 1:
        return False

    for i in range(2, n):
        if n % i == 0:
            return False

    return True

X = int(input())
lis = [i for i in range(1,34)]
num = []

for i in lis:
    for j in range(2, 11):
        if i**j <= X:
            num.append(i**j)

print(max(num))

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    if N == 1:
        print(1)
        exit()

    b, p = 2, 1
    ret = []
    while b ** p <= N:
        if b ** (p + 1) <= N:
            p += 1
            ret.append(b ** p)
        else:
            b += 1
            p = 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
X=int(input())
a=math.sqrt(X)
b=int(a)
ans=1
for i in range (2,b+1):
    for j in range(2,10):
        if i**j <=X <i**(j+1):
            ans=max(ans,i**j)
            break

print(ans)

Submission status: Accepted

Solution code:
X=int(input())
ans=1
for a in range(2,33):
  for b in range(2,11):
    if a**b>X:
      break
    if a**b<=X and a**b>ans:
      ans=a**b
print(ans)

Submission status: Accepted

Solution code:
t = set([])

for i in range(1,32):
    for s in range(2,32):
        if i**s<1001:
            t.add(i**s)
            
t = list(t)

t.append(1001)

t.sort(reverse = True)

x = int(input())

for i in range(len(t)-1):
    if t[i]>x>=t[i+1]:
        print(t[i+1])
        break