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 sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
# https://atcoder.jp/contests/abc097/tasks/abc097_b
X = read_a_int()

# 素因数分解して？いや
# べき乗の数を予め全列挙
candi = []
for i in range(1, 1000 + 1):
    for j in range(2, 11):
        tmp = pow(i, j)
        if tmp > 1000:
            break
        candi.append(tmp)
candi.sort()
print(candi[bisect_right(candi, X) - 1])

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    x = int(input())
    # なんとか^2じゃない
    a = 1
    for i in range(1,x):
        for j in range(2,x):
            if i**j <= x:
                a = max(a,i**j)
            else:
                break
    print(a)
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
ls = [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,1020]
X = int(input())
for i in range(len(ls)):
  if X<ls[i]:
    print(ls[i-1])
    break

Submission status: Accepted

Solution code:
k = []
for i in range(1,40):
  for j in range(2,30):
    if i**j <= 1000:
      k.append(i**j)
L = set(k)
P = list(L)
P.sort()
X = int(input())
ans = 0
if X == 1000:
  print(1000)
else:
  for i in range(len(P)):
    if X<P[i]:
      print(ans)
      break
    else:
      ans = P[i]

Submission status: Accepted

Solution code:
x = int(input())
n = [1]
for i in range(2, 1001):
    p = 2
    while i ** p <= 1000:
        n.append(i ** p)
        p += 1
while not x in n:
    x -= 1

print(x)

Submission status: Accepted

Solution code:
x=int(input())
a=set()
for i in range(1,1001):
  for j in range(2,34):
    t=i**j
    if t<=x:
      a.add(i**j)
a=list(a)
a.sort()
print(a[-1])

Submission status: Accepted

Solution code:
x=int(input())

for i in range(x,-1,-1):
  for k in range(int(i**0.5)+1):
    for j in range(11):
      if k**j>i:
        break
      if k**j==i:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    x = int(input())
    ans = [1]
    for i in range(2, int(x**0.5)+1):
        p = 0
        while i**p <= x:
            ans.append(i**p)
            p += 1
    print(max(ans))
resolve()

Submission status: Accepted

Solution code:
X = int(input())

ans = 0
for i in range(1,1001):
    for j in range(2,11):
        tmp = i ** j
        if tmp <= X:
            ans = max(ans, i ** j)

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
if x == 1:
  print(ans)
  exit()
for i in range(x//2):
  if i**2 <= x < (i+1)**2:
    ans = i**2
    break
    
for i in range(3,10):
  for j in range(ans):
    if ans < j**i <= x:
      ans = j**i
      
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for b in range(2, 32):
    for p in range(2, 10):
        if ans < b**p <= x:
            ans = b**p

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x = int(input())
    m = 0
    for i in range(1, 1000):
        for j in range(2, 100):
            k = pow(i, j)
            if k <= x:
                m = max(m, k)
    print(m)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    x = int(input())
    answer = 1
    b = 2
    while b <= x:
        p = 2
        while pow(b, p) <= x:
            answer = max(answer, pow(b, p))
            p += 1
        b += 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

ans = 1
for i in range(2, X + 1):
    tmp = i ** 2
    while tmp <= X:
        ans = max(ans, tmp)
        tmp *= i
    
print (ans)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    ans = set()
    for i in range(1, 1000):
        for p in range(2, 30):
            if X < i**p:
                break
            ans.add(i**p)
    print(max(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(1,33):
    for j in range(2,11):
        if x >= i**j:
            ans.append(i**j)
print(max(ans))

Submission status: Accepted

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

for i in range(1,34):
    for j in range(2,11):
        if x >= i**j:
            ans.append(i**j)
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

beki = []
for i in range(1,32):
    beki.append(i**2)
for i in range(1,11):
    beki.append(i**3)
for i in range(1,6):
    beki.append(i**4)
for i in range(1,4):
    beki.append(i**5)
for j in range(6,10):
    beki.append(2**j)
    
beki = sorted(beki, reverse=True)
for a in beki:
    if a <= X:
        print(a)
        break

Submission status: Accepted

Solution code:
x=int(input())
ans = 1
if x>=4:
  b=2
  while b**2<=x:
    p=2
    while b**p<=x:
      p+=1
    if b**(p-1)>ans:
      ans=b**(p-1)
    b+=1
print(ans)

Submission status: Accepted

Solution code:
import math
x = int(input())
ans = 1
for i in range(2, int(x ** 0.5) + 1):
    p = 1
    while i ** p <= x:
        p += 1
    ans = max(ans, i ** (p - 1))
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 # b**pがx以上は計算を省く
print(c)

Submission status: Accepted

Solution code:
n = int(input())
array = []
array.append(1)
for i in range(2,32):
  cnt = 2
  num = i**cnt
  while num<=1000:
    array.append(num)
    cnt += 1
    num = i**cnt 

array.sort()
ans = 0
l = len(array)
for i in range(l):
  if array[i]<=n:
    ans = array[i]
print(ans)

Submission status: Accepted

Solution code:
import sys
# input処理を高速化する
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
expo = set()
for i in range(1, 32):
    for j in range(2, 10):
        if i ** j > 1000:
            break
        expo.add(i ** j)
expo = sorted(list(expo), reverse=True)
for e in expo:
    if e <= N:
        print(e)
        exit()

Submission status: Accepted

Solution code:
x=int(input())
n=2
for i in range(x,1,-1):
   for j in range(2,x):
        if i<j:
            break
        n=2
        while j**n<=i:
            if j**n==i:
                print(i)
                exit()
            n+=1
print(x)

Submission status: Accepted

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

ans = 1
for i in range(int(math.sqrt(X))+1):
    for j in range(int(math.sqrt(X))+1):
        if i**j <= X and ans < i**j:
            ans = i**j
print(ans)

Submission status: Accepted

Solution code:
import math
n=int(input())
ans = 1
for i in range(int(math.sqrt(n))+1):
  for j in range(int(math.sqrt(n))+1):
    if i**j <= n and ans < i ** j:
      ans = i**j
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

res = 1
for i in range(2,x+1):
    p = 2
    while i**p<=x:
        res = max(res,i**p)
        p += 1
print(res)

Submission status: Accepted

Solution code:
x = int(input())
mx = 1
for i in range(2,32):
  j = 2
  while i**j <= x:
    if i**j > mx:
      mx = i**j
    j += 1
print(mx)

Submission status: Accepted

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


def ilog(b: int, x: int):
    if b == 1:
        return 0
    lb = 0
    rb = x.bit_length()
    while lb + 1 < rb:
        m = (lb + rb) // 2
        if b ** m <= x:
            lb = m
        else:
            rb = m
    return lb


def solve(X: int):
    print(max(
        b ** ilog(b, X)
        for b in range(1, X + 1)
        if b ** 2 <= X
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
X = int(input())
maxv = [1]

for i in range(1,32):
    for j in range(2,11):
        if i**j > X:
            if j != 2:
                maxv.append(i**(j-1))
            break

print(max(maxv))

Submission status: Accepted

Solution code:
# solution

data=int(input())

array=[]

for i in range(1,34):
  for j in range(2,11):
    if (i**j)<=data:
      array.append(i**j)

print(max(array))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
X = int(input())
ans = 0
if X == 1:
    ans = 1
else:
    for i in range(2,33):
        j = i
        while j*i<=X:
            ans = max(j*i,ans)
            j = j*i
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
X = int(input())

num_list = []
for i in range(1, 33):
    if i ** 2 > X:
        break
    for j in range(2, 11):
        N = i ** j
        if N > X:
            break
        else:
            num_list.append(N)
print(sorted(set(num_list))[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
a = set([1])
for i in range(2, -~1000):
    b = i**2
    while b <= x:
        a = a | set([b])
        b *= i
print(sorted(a)[-1])

Submission status: Accepted

Solution code:
x = int(input())

ans_list = [1]

for i in range(2,x+1):
    cnt = 2
    while True:
        tmp = i ** cnt
        if tmp > x:
            break
        ans_list += [tmp]
        cnt += 1
        
    
ans_list.sort()

for i in ans_list[::-1]:
    if i <= x:
        print(i)
        break

Submission status: Accepted

Solution code:
X = int(input())
List = [0]*(X+1)
List[1] = 1
for i in range(2,X+1):
    v = i**2
    while(v<=X):
        List[v]=1
        v*=i
        
for i in range(1,X+1)[::-1]:
    if List[i]==1:
        print(i)
        break

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    x = ni()

    ans = [1]

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

used = {}
for b in range(2,int(math.sqrt(x))+1):
  p=2
  while(b**p<=x):
    used[b**p]=True
    p+=1

ans=0
for key in used.keys():
  ans = max(ans,key)

print(ans)

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    bpmax=0
    x=int(input())
    for b in range(1,32):
        for p in range(2,10):
            bp=b**p
            if bp<=x:
                bpmax=max(bpmax,bp)
            else:
                break
    print(bpmax)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for i in range(1, x+1):
    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())
H=[1]

i=2
while i<=X**0.5:
    j=2
    while i**j<=X:
        H.append(i**j)
        j+=1
    i+=1

print(sorted(H)[-1])

Submission status: Accepted

Solution code:
def main():
  ans = 0
  n = int(input())
  if n == 1:
    ans = 1
  else:
    for i in range(1, n//2 + 1):
      for j in range(2, 10):
        if ans < i**j <= n :
          ans = i**j
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys
X = int(input())
for i in range(X, 0, -1):
    for j in range(1,32):
        for k in range(2,10):
            if i == j ** k:
                print(i)
                sys.exit()

Submission status: Accepted

Solution code:

def myAnswer(X:int) -> int:
   numbers = [i for i in range(2,X+1)]
   ans = 1
   for p in numbers:
      i = 2
      while True:
         if(p**i <= X):
            ans = max(p**i,ans)
            i += 1
         else:
            break
   return ans


def modelAnswer():
   tmp=1
def main():
   X = int(input())
   print(myAnswer(X))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
import math

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

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 i in range(2, int(x ** 0.5) + 1):
    j = 1
    while i ** j <= x:
        ans = max(ans, i ** j)
        j += 1
print(ans)

Submission status: Accepted

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

answer = max(se)
print(answer)

Submission status: Accepted

Solution code:
# exp = [1]
# b = 2
# while b ** 2 <= 1000:
#     p = 2
#     while b ** p <= 1000:
#         exp.append(b ** p)
#         p += 1
#     b += 1
# exp.sort()
# print(exp)
from bisect import bisect

exp = [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]

x = int(input())
print(exp[bisect(exp, x) - 1])

Submission status: Accepted

Solution code:
List=[1]
for i in range(2,32):
  j=2
  while(i**j<=1000):
    List.append(i**j)
    j+=1
#print(List)
x=int(input())
for i in range(x,0,-1):
  if (List.count(i)>0):
    print(i)
    break

Submission status: Accepted

Solution code:
import math
def main():
    X = int(input())
    ma = 1
    for b in range(2, X):
        for p in range(2, X):
            if b**p <= X:
                if ma < b**p:
                    ma = b**p
            else:
                break
    print(ma)  
main()

Submission status: Accepted

Solution code:
# ABC 097: B – Exponential
x = int(input())
e = 0

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

print(e)

Submission status: Accepted

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

num = 1
for i in range(1 ,int(sqrt(x) + 1)):
    for j in range(2, 100):
        if i ** j <= x:
            num = max(num, i ** j)
        else:
            break 

print(num)

Submission status: Accepted

Solution code:
x = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

ans = 0
i = 1
p = 2
if x == 1:
    print(1)
else:
    while p <= 1000:
        while pow(p, i) <= x:
            if pow(p, i)<= x:
                ans = max(ans, pow(p, i))
            i += 1
        i = 2
        p += 1
    print(ans)

Submission status: Accepted

Solution code:
import math
X = int(input())
c = 1
for b in range(2,math.floor(math.sqrt(X)+1)):
  p = 2
  while b**p <= X:
    p+=1
  c = max(c,b**(p-1))
print(c)

Submission status: Accepted

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    x = II()
    if x == 1: print(1); exit(0)
    b = 2; p = 2
    maxv = 0
    while True:
        if b**2 > x: break
        if b**p > x:
            maxv = max(maxv, b**(p-1))
            b += 1; p = 2
            continue
        p += 1
    print(maxv)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
q=[j**k for j in range(1,32) for k in range(2,11)]
for i in range(len(q)):
  if q[i]>1000:
    q[i]=0
q.sort(reverse=True)
x=0
while q[x]>n:
  x+=1
print(q[x])

Submission status: Accepted

Solution code:
import math

x = int(input())

ans = 0
exponent = []

for i in range(1,int(math.sqrt(x))+1):
  for j in range(2, int(math.log(x, 2))+1):
    ans = i ** j
    exponent.append(ans)

exponent.sort()
exponent = [i for i in exponent if i <= x]

if x == 1:
  print(1)
else:
  print(max(exponent))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
b=set()
ans=0
for i in range(1,a+1):
    for j in range(1,33):
        for k in range(2,10):
            if j**k==i:
                ans=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
li = []
for i in range(1,100):
    for j in range(2,20):
        if i**j<=10000:
            li.append(i**j)
li2 = list(set(li))
li2.sort()
ans = 0
for k in range(len(li2)):
    if (li2[k-1]<=N)&(li2[k]>N):
        ans = li2[k-1]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
max_n = 0
for i in range(1000+1):
  for j in range(2,1000+1):
    if i**j > max_n:
      if i**j <=N:
        max_n = i**j
      else:
        break 
print(max_n)

Submission status: Accepted

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

p = [1]

for i in range(1, X):
    for j in range(2, 11):
        if i**j <= X:
            p.append(i**j)
        else:
            break

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

Submission status: Accepted

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

y=sorted(y)
print(y[-1])

Submission status: Accepted

Solution code:
X = int(input())

l = []
for i in range(1, 32):
    for j in range(2, 10):
        if i ** j <= 1000:
            l.append(i ** j)

l = sorted(list(set(l)), reverse = True)

for i in range(len(l)):
    if l[i] <= X:
        print(l[i])
        break

Submission status: Accepted

Solution code:
# AtCoder
import math
X = int(input())
ans = 0

for i in range(1, math.floor(math.sqrt(X)+1)):
    for j in range(1, math.floor(math.sqrt(X)+1)):
        if i**j <= X:
            ans = max(i**j, ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
l=[]
for i in range(1,1000+1):
    for k in range(2,11):
        z = i**k
        if z <= x:
            l.append(z)
print(max(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

res = []
for i in range(1, 33):
  for j in range(2, 10):
    cand = i ** j
    if x >= cand:
      res.append(cand)
res = sorted(res)
print(res[-1])

Submission status: Accepted

Solution code:
X=int(input())

root_list=[]
for i in range(1,33):
  for j in range(2,10):
    if i**j<=X:
      root_list.append(i**j)

root_list.sort()
#print(root_list)
print(root_list[-1])

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

b = 2
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
print(sorted([b ** p if b ** p <= x else 1 for b in range(1, 1001) for p in range(2, 11)])[-1])

Submission status: Accepted

Solution code:
x = int(input())
a = list()
a.append(1)
for i in range(2,32):
    j = 2  
    while i**j<1001:
        a.append(i**j)
        j= j+1
a = sorted(a)[::-1]
for i in range(len(a)):
    if a[i]<=x:
        print(a[i])
        break

Submission status: Accepted

Solution code:
x = int(input())
s = []
for p in range(2, 11):
    for b in range(1, 1001):
        if b ** p <= x:
            s.append(b ** p)
        else:
            break
print(sorted(s)[-1])

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    X = int(input().strip())
    if X==1:
        print(1)
        return
    ans=0
    for i in range(2,32):
        for j in range(2,100000):
            if i**j>X:
                break
            else:
                ans=max(ans,i**j)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x=int(input())
beki=1
for b in range(1,int(1000*0.5)+1):
    for p in range(2,10):
        if b**p<=x:
            beki=max(beki,b**p)
print(beki)

Submission status: Accepted

Solution code:
import sys

def resolve():
    X = int(input())
    cands = [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]
    for i in range(len(cands)):
        if cands[i] > X:
            print(cands[i-1])
            return
    print(cands[-1])

if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
x = int(input())

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

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

Submission status: Accepted

Solution code:
# from sys import stdin
import math

X = int(input())

# for i in range(33):
ans = 0
for i in range(int(math.sqrt(X))+1):
    for x in range(11):
        # print(i,x)
        if i**x <= X and i**x > ans:
            ans = i**x
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = [1]
for i in range(2, 100):
    for j in range(2,100):
        b.append(i**j)
b.sort()
for i in range(1,len(b)):
    if b[i] > a:
        print(b[i-1])
        break

Submission status: Accepted

Solution code:
X = int(input())

ans = 1

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

Submission status: Accepted

Solution code:
import math
X = int(input())
i_max = math.floor(math.sqrt(X))

result = 1
for i in range(2,i_max+1,1):
    for j in range(2,X):
        n = (i**j)
        if (n > X):
            break
        else:
            result = max(result, n)

print(result)

Submission status: Accepted

Solution code:
import math
X = int(input())
i_max = math.floor(math.sqrt(X))

result = 1
for i in range(2,i_max+1,1):
    for j in range(1,X):
        n = (i**j)
        if (n > X):
            break
        else:
            result = max(result, n)

print(result)

Submission status: Accepted

Solution code:
import sys
x = int(input())
if (x == 1000):
    print(1000)
    sys.exit()
list = []
list.append(1)
for i in range(30):
    tmp = (i+2)**2
    while (tmp <= 1000):
        list.append(tmp)
        tmp = tmp*(i+2)
list.sort()
tmp = list[0]
for i in list:
    if (i > x):
        print(tmp)
        sys.exit()
    tmp = i

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
vis = [False for _ in range(x+1)]
vis[1] = True
for i in range(2,x+1):
  tmp = i*i
  while tmp < x+1:
    vis[tmp] = True
    tmp *= i
best = 1
for i in range(1,x+1):
  if vis[i]:
    best = i
print(best)

Submission status: Accepted

Solution code:
x=int(input())
l=[1]
for i in range(2,int(x**0.5)+1):
    j=1
    while i**(j+1)<=x:
        j+=1
    l.append(i**j)

#print(l)
print(max(l))

Submission status: Accepted

Solution code:
L = [0 for _ in range(1001)]
L[1] = 1
for i in range(2, 32):
  base = i * i
  while base <= 1000:
    L[base] = 1
    base *= i
X = int(input())
while L[X] == 0:
  X -= 1
print(X)

Submission status: Accepted

Solution code:
X = int(input())

lst=[1]
for p in range(2,10):
    i=2
    while i ** p <= X:
        lst.append(i ** p)
        i+=1
#print(lst)
print(max(lst))

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

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

Submission status: Accepted

Solution code:
X = int(input())
limit = int(X ** 0.5)
ans = -1
prob_ans = []

if X == 1:
    ans = 1
for i in range(2, limit+1):
    p = 2
    while True:
        tmp = i ** p
        if tmp > X:
            break
        ans = max(ans, tmp)
        p += 1

print(ans)

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
X = I()
kouho = []
ans = 1
kouho.append(1)
for i in range(2,1000):
    j = 1
    while i**j<=1000:
        j += 1
        if i**j<=1000:
            kouho.append(i**j)
kouho.sort()
for x in kouho:
    if x<=X:
        ans = x
    else:
        break
print(ans)