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:
#abc97 b
x=int(input())

beki=[1]

def gene_beki():
    for b in range(2,36):
        for p in range(2,10):
            num=b**p
            if num>x:
                continue
            else:
                beki.append(num)
gene_beki()
print(max(beki))

Submission status: Accepted

Solution code:
s = int(input())

snooker =[0]*1000

for p in range (1, 100):
	for q in range (2, 10):
		if p**q<=10000:
			snooker[10*(p-1)+q-1]=p**q

snooker = [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, 1024, 1089, 1156, 1225, 1296, 1331, 1369, 1444, 1521, 1600, 1681, 1728, 1764, 1849, 1936, 2025, 2116, 2187, 2197, 2209, 2304, 2401, 2500, 2601, 2704, 2744, 2809, 2916, 3025, 3125, 3136, 3249, 3364, 3375, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 4913, 5041, 5184, 5329, 5476, 5625, 5776, 5832, 5929, 6084, 6241, 6400, 6561, 6724, 6859, 6889, 7056, 7225, 7396, 7569, 7744, 7776, 7921, 8000, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9261, 9409, 9604, 9801, 10000]

slist = [0]*123

for i in range (0, 123):
	if snooker[i]<=s:
		slist[i]=snooker[i]
      
print(max(slist))

Submission status: Accepted

Solution code:
import math

x=int(input())
a=int(math.sqrt(x)//1)
ans=1
for i in range(1,a+1):
    for j in range(2,a+1):
        if i**j<=x:
            ans=max(ans,i**j)
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
ans=[1]
for i in range(2,x+1):
    k=2
    while True:
        a=i**k
        if a<=x:
            ans.append(a)
            k+=1
        else:
            break
print(max(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

x=ii()

ans=1

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

Submission status: Accepted

Solution code:
X = int(input())

max_ans = 0
for i in range(1, X+1):
    for j in range(2, X+1):
        if i ** j > X:
            break
        max_ans = max(max_ans, i**j)
print(max(1, max_ans))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
if n == 1 or n == 2 or n == 3:
    ans = 1
for i in range(2, 10001):
    b = i
    c = i
    cnt = 0
    while True:
        if c*b > n:
            break
        cnt += 1
        c *= b
    if cnt != 0:
        ans = max(ans, c)

print(ans)

Submission status: Accepted

Solution code:
x = int(input())

res = 0
for i in range(1, 1001):
    for j in range(2, 1001):
        t = pow(i, j)
        if t <= x:
            res = max(res, t)
        else:
            break

print(res)

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
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)
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
x=int(input())
k=[]
for i in range(1,32):
    if abs(x-i**2)<=min(abs(x-i**3),abs(x-i**7),abs(x-i**5)):
        if i**2<=x:
            k.append([abs(x-i**2),i**2])
    elif abs(x-i**3)<=min(abs(x-i**2),abs(x-i**7),abs(x-i**5)):
        if i**3<=x:
            k.append([abs(x-i**3),i**3])
    elif abs(x-i**5)<=min(abs(x-i**3),abs(x-i**2),abs(x-i**7)):
        if i**5<=x:
            k.append([abs(x-i**5),i**5])
    elif abs(x-i**7)<=min(abs(x-i**3),abs(x-i**2),abs(x-i**5)):
        if i**7<=x:
            k.append([abs(x-i**7),i**7])
k.sort()
print(k[0][1])

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = int(input())

lis = []

for i in range(1,1001):
	for j in range(2,11):
		lis.append(i**j)

cand = [i for i in lis if i<=x]

print(max(cand))

Submission status: Accepted

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

ans = 1
i = 1
for i in range(2, int(sqrt(x)) + 1):
    j = i
    while j <= x:
        j *= i
    
    ans = max(ans, j // i)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

sub = []
for i in range(1, 100):
    for j in range(2, 100):
        sub.append(i ** j)

sub.sort()
for i in range(len(sub)):
    if sub[i] > x:
        ans = sub[i - 1]
        break

print(ans)

Submission status: Accepted

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

    ans = 0
    if X <= 3:
        ans = 1
    else:
        for b in range(2,100):
            if b ** 2 > X:
                break
            p = 2
            while pow(b,p) <= X:
                p += 1
            else:
                ans = max(ans, pow(b,p-1))
    
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
X = int(input())
A = 1
for i in range(2, X):
  if A == X:
    print(A)
    exit()
  j = 2
  t = i ** j
  while i ** j <= X:
    if i ** j > A:
      A = i ** j
    else:
      j += 1
print(A)

Submission status: Accepted

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

for i in range(1000):
    for j in range(2,10):
        k = i**j
        if k >1000:
            break
        else:
            beki.append(k)
            
for i in range(x):
    if x-i in beki:
        print(x-i)
        break

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d[i] = cnt
    
    if temp!=1:
        d[temp] = 1
    
    if len(d) == 0:
        d[n] = 1
    
    return d

def check(d):
  v = d[0]
  if v == 1:
    return False
  for _v in d:
    if _v != v:
      return False
  return True

X = int(input())
for x in range(X, 1, -1):
  d = list(factorization(x).values())
  if check(d):
    print(x)
    quit()
  
print(1)

Submission status: Accepted

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

if x >= 4:
    tei = 2
    while True:
        beki = 2
        if tei >= x:
            break
        else:
            while tei ** beki <= x:
                ans = max(ans, tei ** beki)
                beki = beki + 1
            tei = tei + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

li = []
for x in range(2,10):
  li += [ i**x for i in range(1,int(1000**(1/x)//1)+2)]
ans_list = sorted(list(set(li)), reverse=True)

for x in ans_list:
  if x <=X:
    print(x)
    break

Submission status: Accepted

Solution code:

x = int(input())
ans = 1

for i in range(1,32):
    for j in range(2,11):
        if i ** j > x:
            pass
        else:
            if ans < i ** j:
                ans = i ** j
#                print(i,j)

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for base in range(1, 101):
    for p in range(2, 10):
        if base**p > x:
            break
        ans = max(ans, base**p)

print(ans)

Submission status: Accepted

Solution code:
import math
x = int(input())
ans = []
for j in range(1, math.ceil(math.sqrt(x)) + 1):
    for k in range(2,x + 2):
        if j ** k <= x:
            ans.append(j ** k)
print(max(ans))

Submission status: Accepted

Solution code:
X = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
l1 = [1]
l2 = list(2**i for i in range(2,11))
l3 = list(3**i for i in range(2,7))
l4 = list(4**i for i in range(2,6))
l5 = list(5**i for i in range(2,5))
l6 = list(6**i for i in range(2,5))
l7 = list(7**i for i in range(2,5))
l8 = list(8**i for i in range(2,5))
l9 = list(9**i for i in range(2,5))
l10 =list(10**i for i in range(2,4))
l11 = list(i**2 for i in range(11,34))
l1 = list(set(l1+l2+l3+l4+l5+l6+l7+l8+l9+l10+l11))
if x in l1:
  print(x)
else:
  l1.append(x)
  l1.sort()
  a = l1.index(x)-1
  print(l1[a])

Submission status: Accepted

Solution code:
from math import sqrt
x = int(input())
cnt = 0
l = []
for i in range(1, x + 1):
    for j in range(1, int(sqrt(i)) +1):
        for k in range(2, 10):
            if j ** k == i:
                l.append(i)
print(max(l))

Submission status: Accepted

Solution code:
import math
X=int(input())
res=0
for b in range(1,int(math.sqrt(X)+1)):
    for p in range(2,int(math.sqrt(X))+2):
        val=b**p
        if (val<=X)and(val>res):
            res=val
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

dekai = 0
for j in range(2, 13):
    l = [i**j for i in range(1, 35) if i**j <= N]
    if max(l) > dekai:
        dekai = max(l)

print(dekai)

Submission status: Accepted

Solution code:
from math import pow
l = []
l.append(1)
l.append(2 ** 2)
l.append(2 ** 3)
l.append(2 ** 4)
l.append(2 ** 5)
l.append(2 ** 6)
l.append(2 ** 7)
l.append(2 ** 8)
l.append(2 ** 9)
l.append(3 ** 2)
l.append(3 ** 3)
l.append(3 ** 4)
l.append(3 ** 5)
l.append(5 ** 2)
l.append(5 ** 3)
l.append(5 ** 4)
l.append(6 ** 2)
l.append(6 ** 3)
l.append(7 ** 2)
l.append(7 ** 3)
l.append(10 ** 2)
l.append(10 ** 3)
for i in range(11, 32):
    l.append(i ** 2)
def print_exponential(integer):
    while integer > 0:
        if integer in l:
            break
        else:
            integer -= 1
    print(integer)
X = int(input())
print_exponential(X)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
ans=1
for i in range(34,1,-1):
    cur=i
    while cur<=x:
        cur*=i
        if cur<=x:
            ans=max(ans,cur)
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:
def Exponential(x):

    ans = 0
    if x == 1:
        ans = 1
    else:
        for i in range(1, x + 1):
            for w in range(2, x + 1):
                if i ** w > x:
                    break
                else:
                    ans = max(ans, i ** w)

    return ans

def main():
    x = int(input())
    print(Exponential(x))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    import math
    from itertools import product
    x = int(input())
    k = math.ceil(x ** .5)
    l = [1]

    for i, j in product(range(2, k), range(2, 10)):
        if i ** j <= 1000:
            l.append(i ** j)
    ans = max([i for i in l if i <= x])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = 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] > X:
        print(b[i-1])
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
y = 0
if x==1 or x==2 or x==3 or x==4:
    print(1)
    exit()
else:
    for a in range(2,(x+1)):
        for b in range (2,10):
            if b==2 and a**b>x:
                print(y)
                exit()
            elif a**b<=x:
                y=max(a**b,y)

Submission status: Accepted

Solution code:
x = int(input())
y = 0
if x==1 or x==2 or x==3:
    print(1)
    exit()
else:
    for a in range(2,(x+1)):
        for b in range (2,10):
            if b==2 and a**b>x:
                print(y)
                exit()
            elif a**b<=x:
                y=max(a**b,y)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
if x == 1 or x == 2 or x == 3:
  print(1)
  exit()
  
for i in range(2,33):
  for k in range(2,10):
    if k == 2 and i**k > x:
      print(ans)
      exit()
    elif i**k <= x:
      ans = max(i**k,ans)

Submission status: Accepted

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

for i in range(1,100):
  for j in range(2,20):
    if i**j<=X:
      ans=max(ans,i**j)
      
print(ans)

Submission status: Accepted

Solution code:
def main():
    x = int(input())
    ans = 1
    for b in range(x, 1, -1):
        p = 2
        ans_temp = -float("inf")
        while True:
            if b**p > x:
                break
            ans_temp = b**p
            p += 1
        ans = max(ans, ans_temp)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

ans=0
for i in range(1000):
  for j in range(2,11):
    if i**j<=N and ans<i**j:
      ans=i**j
      
      
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
a=1000
b=100
li=[]
ans=0

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

for j in range(1,x+1):
    if j in li:
        ans=j

print(ans)

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for i in range(2, x+1):
    for j in range(2, x+1):
        if 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, x+2):
    for j in range(2, x+2):
        if i**j <= x:
            ans = max(ans, i**j)
        else:
            break

print(ans)

Submission status: Accepted

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

if X == 1:
  print(X)
  exit()
else:
  # p
  for i in range(2, int(X**0.5)+1):
    n=1
    a=i
    # b
    while n < X : #超えたら中断
      n *= a
      ans.append(n)
    if n // a > x:
      x = (n//a)
      #print(ans)
print(max(i for i in ans if i <= X))

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for i in range(2,X+1):
    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())
l = []
if X == 1:
    print(1)
else:
    for b in range(2, int(X ** 0.5) + 1):
        for p in range(2, 2 ** 10):
            if b **p <= X:
                l.append(b ** p)
    print(max(l))

Submission status: Accepted

Solution code:
X = int(input())

A = []
if X < 4:
    ans = 1
else:
    for b in range(2, int(X ** 0.5) + 1):
        t = b ** 2
        while t <= X:
            A.append(t)
            t *= b
    A.sort()
    ans = A[-1]

print(ans)

Submission status: Accepted

Solution code:
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

x = int(input())
a = [1]
for i in range(2, 1001):
    for j in range(2, 10):
        a.append(i**j)
aa = sorted(set(a))
# print(aa)
b = []
for i in range(len(aa)):
    if aa[i] <= x:
        b.append(aa[i])
print(max(b))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
X=int(input())
numbers=[1]
for b in range(1,X+1):
    for p in range(2,X+1):
        if b**p<=X:
            numbers.append(b**p)
        elif b**p>X:
            break
print(max(numbers))

Submission status: Accepted

Solution code:
X=int(input())
li=[x**p for x in range(1,32) for p in range(2,35) if x**p<=X]
print(max(li))

Submission status: Accepted

Solution code:
def main(x: int):
    ans = set([1])

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

            ans.add(b**p)

    print(max(ans))


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

    main(x)

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    X=int(input())
    ans=0
    for i in range(2,1000):
        for j in range(1,1000):
            if j**i<=X:
                ans=max(ans,j**i)
            else:
                break

    print(ans)


resolve()

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for n in range(2,32):
    a = n*n
    while a <= X:
        ans = max(ans, a)
        a *= n
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:
# coding: utf-8

def beki(num:int):
    if num == 1:
        return [1]
    ans = [1]
    for i in range(2, num + 1):
        for j in range(2, num+1):
            tmp = pow(i,j)
            if tmp > num:
                break
            ans.append(tmp)
    return set(ans)

n = int(input().rstrip())
beki_list = beki(n)
print(max(beki_list))

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for i in range(2,X):
    j = 2
    if i**j > X:
        continue
    while i**j <= X:
        j+=1
    ans = max(ans,i**(j-1))
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
s = [1]
for i in range(2, 32):
    if not i in s:
        n = i * i
        while True:
            if n <= 1000 and not n in s:
                s.append(n)
            if n > 1000:
                break
            n *= i
s.sort()
for i in s:
    if i <= x:
        ans = i
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    x = int(input())
    for i in range(x, 0, -1):
        for b in range(1, 35):
            for p in range(2, 10):
                if b**p==i:
                    print(i)
                    exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
res = 0
for i in range(1,33):
  for j in range(2,11):
    tmp = pow(i, j)
    if tmp <= n:
      res = max(res, tmp)
print(res)

Submission status: Accepted

Solution code:
X = int(input())

print(max([pow(b, p) for b in range(1, 1001) for p in range(2, 11) if pow(b, p) <= X]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

X_half = X // 2
max_ans = 1
tmp_max = 0

for i in range(1,X_half+10):
    for j in range(2,X_half+10):
        tmp = i ** j
        if tmp<=X:
            tmp_max = tmp
    max_ans = max(max_ans, tmp_max)

print(max_ans)

Submission status: Accepted

Solution code:
import sys
import os


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

    N = int(sys.stdin.readline().rstrip())
    ret = 1
    for b in range(1, N):
        for p in range(2, N//2):
            if b ** p <= N:
                ret = max(ret, b ** p)

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x=int(input())
i,j=2,1
ans=[]
if x==1:
    print(1)
    quit()
while True:
    j+=1
    if i**j>x:
        i+=1
        j=2
        if i**j>x:
            break
    ans.append(i**j)
print(max(ans))

Submission status: Accepted

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

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

print(ans)

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())
upper = int(X**0.5//1)+1
max = 0
for x in range(1,upper):
  for i in range(9):
    if max < x**(i+1) <= X:
      max = x ** (i+1)
print(max)

Submission status: Accepted

Solution code:
x=int(input())
ans=1
for i in range(40):
    for j in range(2,15):
        if i**j<=x and i**j>ans:
            ans=i**j
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
r=int(x**0.5)
a=1
for b in range(r+1):
    for p in range(10):
        if b**p <=x :
            a=max(a,b**p)
        else:
            break
print(a)

Submission status: Accepted

Solution code:
X = int(input())
ans = []
for b in range(1, 100):
    for p in range(2, 50):
        ans.append(b**p)
ans = [i for i in ans if i <= X]
ans.sort(reverse = True)
print(ans[0]) if X!=1 else print(1)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for b in range(int(n ** 0.5) + 1):
    for p in range(int(n ** 0.5) + 1):
        if b ** p <= n:
            if ans < b ** p:
                ans = b ** p
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = [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]
X = int(input())
while 1:
  if X in l:
    print(X)
    break
  X -= 1

Submission status: Accepted

Solution code:
# Author: cr4zjh0bp
# Created: Fri Mar  6 03:27:57 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

x = ni()

ans = 1
i = 2
while i * i <= x:
    t = i * i
    while t <= x:
        ans = max(ans, t)
        t *= i
    i += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

expo = []
for i in range(1,10000):
    if i == 1:
        expo.append(i)
    else:
        for j in range(2,1000):
            tmp = i**j
            if tmp > N:
                break
            expo.append(tmp)
expo.sort()

expo = np.array(expo)

print(max(expo[expo<=N]))

Submission status: Accepted

Solution code:
x = int(input())

l = []
for i in range(1,35):
    for y in range(2,35):
        if i ** y <= x:
            l.append(i**y)
        else:
            break
l.sort()
print(l[-1])

Submission status: Accepted

Solution code:
X = int(input())

max_v = 1
b = 2
for i in range(2, X):
  b =i
  for j in range(2,X):
    p = j
    if b**p > max_v and b**p <= X:
      #print(b, p)
      max_v = b**p
    elif b**p > X:
      break
print(max_v)

Submission status: Accepted

Solution code:
N=int(input())
a = 2
ans = 1
while a * a <= N:
  b = a
  while b <= N:
    ans = max(ans,b)
    b *= a
  a+=1
print(ans)

Submission status: Accepted

Solution code:
#abc097 b bekijousu
import math

def large_num(n):
    xx=x/n
    p=1
    while xx-n**p>=0:
        p+=1
    if p==1:
        return 0
    else:
        return n**p

x=int(input())
b_last=int(math.sqrt(1000))
num=[i for i in range(2,b_last+1)]

ans=0


if 4>x:
    ans=1
else:
    for i in num:
        ans=max(large_num(i),ans)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

ans = 1

i = 2

while i**2 <= n:
    u = 2
    while i**u <= n:
        ans = max(i**u, ans)
        u += 1
    i += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = -1
for i in range(1,33):
  for j in range(2,15):
    if ans < i**j <= n:
      ans = i**j
print(ans)

Submission status: Accepted

Solution code:
#ABC097
import math
x = int(input())
l = [1]
for i in range(int(math.sqrt(x))+1):
    for j in range(2,100):
        if i ** j > x:
            l.append(i ** (j-1))
            break
            
print(max(l))

Submission status: Accepted

Solution code:

x=int(input())
a=[]
ans=0

for i in range(1,32):
            for j in range(2,10):
                        ans=i**j
                        if ans<=x:
                                    a.append(ans)   
                                    #i+=1
                        else:
                                    break
                        
            #print(a)
print(max(a))
"""
while ans<x:
"""

Submission status: Accepted

Solution code:
import bisect

x = int(input())


def expo(n):
    expo_l = [1]
    for i in range(2, 101):
        j = 2
        while i ** j <= 1000:
            expo_l.append(i ** j)
            j += 1
    return expo_l


dic = expo(x)
dic = sorted(list(set(dic)))
index = bisect.bisect_right(dic, x)
print(dic[index - 1])

Submission status: Accepted

Solution code:
n = int(input())
A = []
for i in range(40):
    for j in range(2, 20):
        A.append(i**j)

A = sorted(A)
ans = 0
for i in A:
    if i <= n:
        ans = i
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
beki=set([1])

for b in range(2,n+1):
    for p in range(2,100):
        if b**p<=n:
            beki.add(b**p)

beki=list(beki)
beki.sort()
print(beki[-1])

Submission status: Accepted

Solution code:
import bisect
X=int(input())
s=set()
for i in range(1,1000):
    for j in range(2,11):
        if(i**j<=X):
            s.add(i**j)
        else:
            break
li=sorted(s)
print(li[bisect.bisect_right(li,X)-1])