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:
x = int(input().strip())
ans = 0
for b in range(1, 1001, 1):
    for p in range(2, 1001, 1):
        rep = b ** p
        if x < rep:
            break
        ans = max(ans, rep)
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())
ans=0
for i in range(1,x+1):
  for j in range(2,12):
    if i**j<=x:
      ans=max(ans,i**j)
    else:
      break
print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
max = 0
for i in range(int(math.sqrt(N)+1)):
	for j in range(10):
		if(i**j>max and i**j <=N):
			max = i**j
print(max)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = input()
y = 1
for i in range(1, 1001):
    for n in range(2, 10):
        if i ** n <= x and i ** n > y:
            y = i ** n
print y

Submission status: Accepted

Solution code:
x = int(input())
ans = []
for i in range(1, 1000):
    for j in range(2, 11):
        if i**j <= x:
            ans.append(i**j)
print(sorted(ans)[-1])

Submission status: Accepted

Solution code:
x = input()
ans = 1
for b in range(1, 1001):
    for p in range(2, 10):
        if b ** p <= x and b ** p > ans:
            ans = b ** p
print ans

Submission status: Accepted

Solution code:
import sys
X = int(input())
L = []
for i in range(1,32):
  for j in range(1,10):
    if X < i**j:
      if j != 2:
        L.append(i**(j-1))
        break
      break
    elif X == i**j and j != 1:
      print(i**j)
      sys.exit(0) #平方数忘れ
print(max(L))

Submission status: Accepted

Solution code:
import math

X = int(input())
ans = 1

for b in range(2, math.ceil(math.sqrt(X)) + 1):
    p = 2

    while b ** p <= X:
        p += 1

    ans = max(ans, b ** (p - 1))

print(ans)

Submission status: Accepted

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

cand=[0,1]
for i in range(2,32):
    temp=i
    while True:
        temp*=i
        if temp<=1000:
            cand.append(temp)
        else:
            break

cand.sort()

X=int(input())

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

for i in range(1,len(cand)):
    if X<cand[i]:
        print(cand[i-1])
        exit()

Submission status: Accepted

Solution code:
x = int(input())

result = 0
for i in range(2,x+1):
  beki = 2
  while (i**beki) <= x:
    if result < i**beki:
      result = i**beki 
    beki+=1

if result == 0:
  print(1)
else:
  print(result)

Submission status: Accepted

Solution code:
x = int(input())
seen = [0] * 1001
ans = 1
for i in range(x):
    if(seen[i]): pass
    cur = i
    if(i > 1):
        while (cur <= x):
            cur *= i
            if(cur <= x): ans = max(ans, cur)
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

x = 0

L = [0]

if X == 1:
  print(X)

else:
  for i in range(2,int(X ** 0.5) + 1):
    n = 1
    a = i
    while n < X :
      n *= a
      L.append(n)
    if n // a > x:
      x = (n // a)
  
  print(max(i for i in L if i <= X))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

ans = []
for i in range(1, 1000):
    for j in range(2, 11):
        if i**j > X:
            continue
        ans.append(i**j)
print(max(ans))

Submission status: Accepted

Solution code:
import math
x = int(input())
seen = [0] * 1001
ans = 1
for i in range(x):
    if(seen[i]): pass
    cur = i
    if(i > 1):
        while (cur <= x):
            cur *= i
            if(cur <= x): ans = max(ans, cur)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

maxv = 0
for i in range(1,100):
    for j in range(2,100):
        a = i ** j
        a = max(a, i**j)
        if i ** j <= x and maxv < a:
            maxv = a

print(maxv)

Submission status: Accepted

Solution code:
# coding: utf-8
X=int(input())
A=[]
for i in range(1,X+1):
    for j in range(2,X+2):
        if i**j<=X:
            A.append(i**j)
        else:
            break
A.sort()
#print(A)

print(A[len(A)-1])

Submission status: Accepted

Solution code:
# coding: utf-8

X=int(input())

ans=1

for i in range(2,35):
    k=2
    while i**k<=X:
        k+=1
    if k>=3:
        ans=max(ans,i**(k-1))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())
out=1
for i in range(2, int(pow(X, 1/2))+1):
  j=2
  while i**(j+1)<=X:
    j+=1
  if out<i**j:
    out=i**j
print(out)

Submission status: Accepted

Solution code:
X = int(input())
def is_beki(N):
    for i in range(2,int(N**.5)+1):
        if N%(i**2)==0:
            k = 1
            while k<N:
                k *= i
            if N == k:
                return True
    return False

for x in range(X, 1, -1):
    if is_beki(x):
        print(x)
        break
else:
    print(1)

Submission status: Accepted

Solution code:
x=int(input())

ans=1

for i in range(2,x):
  a=i
  while a*i<=x:
    a*=i
  if i<a and ans<a:
    ans=a

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
r = 0
for b in range(1, int(x**0.5)+1):
    for q in range(1, x+1):
        t = b**q
        if r < t <= x:
            r = t
        if t > x:
            break
print(r)

Submission status: Accepted

Solution code:
import  math
 
n = int(input())
s = math.floor(math.sqrt(n))

ans = s ** 2
for i in range(2, s):
    m = 0 
    while i ** (m+1) <= n:
        m += 1
        ans = max(ans, i ** m)

print(ans)

Submission status: Accepted

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

sq = int(math.sqrt(X))

m = 1
for b in range(2, sq+1):
    p = 2
    tmp = b ** p
    while tmp <= X:
        m = max(tmp, m)
        p += 1
        tmp = b ** p

print(m)

Submission status: Accepted

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

sq = int(math.sqrt(X))

candidates = [1]
for b in range(2, sq+1):
    p = 2
    tmp = b ** p
    while tmp <= X:
        candidates.append(tmp)
        p += 1
        tmp = b ** p

print(sorted(candidates)[-1])

Submission status: Accepted

Solution code:
x = int(input())

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

max = 1
for b in range(1, x+1):
   for p in range(2, x+1):
      c = b**p
      if (c > x):
         break
      elif (max <= c):
         max = c
print(max)

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
# まあ探索しましょうや 最低の2でも10回やりゃ1000越えるんだし
ans = 0
x = int(input())
if x == 1:
    print(1)
    exit()
for b in range(2, int(x * 0.5) + 1):
    p = 2
    while True:
        if b ** p > x:
            break
        ans = max(ans, b ** p)
        p += 1
print(ans)

Submission status: Accepted

Solution code:
import math
x=int(input())
y=math.ceil(math.sqrt(x))
ans=1
for i in range(y):
    for j in range(y):
        if ans<=i**j<=x:
            ans=i**j
        else:
            continue
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
l = [1]
for i in range(2,32):
  p = 2
  while i ** p <= 1000:
   l.append(i ** p)
   p += 1

while not X in l:
  X -= 1

print(X)

Submission status: Accepted

Solution code:
x = int(input())

s = set([1])
for i in range(2,x):
    for j in range(2,10):
        if (i**j) <= x:
            s.add(i**j)

print(max(list(s)))

Submission status: Accepted

Solution code:
x = int(input())

s = set([1])
for i in range(2,501):
    for j in range(2,10):
        if (i**j) <= x:
            s.add(i**j)

print(max(list(s)))

Submission status: Accepted

Solution code:
x = int(input())

s = set([1])
for i in range(2,501):
    for j in range(2,501):
        if (i**j) <= x:
            s.add(i**j)

print(max(list(s)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
X = int(input())
x = int(X ** (1/2))
ans = 1
for i in range(2,x+1) :
    a = 1
    e = 0
    while a == 1 :
        k = i ** e
        if k > X :
            k = i ** (e-1)
            a = 0
            break
        e+=1
    ans = max(ans,k)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
X = int(input())
bp = {b**p for b in range(1,int(math.sqrt(X))+1) for p in range(2,10) if b**p <= X}
print(max(bp))

Submission status: Accepted

Solution code:
x = int(input())

res = []

for i in range(2, int(x**0.5)+2):
    for j in range(2, 10):
        if i**j <= x:
            res.append(i**j)
if x == 1:
    print(1)
else:
    print(max(res))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
X = int(input())
ans = [1]
for i in range(2, 1 + int(X ** (1/2))):
    ans.append(i)
    x = i
    while x < X:
        x *= i
        if x <= X:
            ans.append(x)
print(max(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
X = int(input())

ans = 1
b = 2
while X >= b :
  p = 2
  while X >= b**p :
    ans = max(ans, b**p)
    p += 1
  b += 1
print (ans)

Submission status: Accepted

Solution code:
def main():
    x = int(input())
    ans = 0
    d = 0
    if x == 1:
        return 1
    for i in range(2, x):
        d = i
        p = 2
        while d ** p <= x:
            ans = max(ans, d ** p)
            p += 1
    return ans


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

Submission status: Accepted

Solution code:
from bisect import bisect_left
import math
n = int(input())
lst = []
lst.append(1)
for i in range(2, int(math.sqrt(1000)) + 1):
    for j in range(2, 10):
        if i ** j <= 1000 and i ** j not in lst:
            lst.append(i ** j)

lst.sort()
print(lst[bisect_left(lst, n) - 1] if n not in lst else lst[bisect_left(lst, n)])

Submission status: Accepted

Solution code:
import numpy as np
X = int(input())
ans = 1
for b in range(2, 1+int(np.ceil(np.sqrt(X)))):
    p = 0
    while np.power(b, p) <= X:
        p += 1
    p -= 1
    ans = max(ans, np.power(b, p))
print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
if n == 1:
    print(1)
    exit()
minx = int(math.sqrt(n)//1)
ans = 0
for i in range(2,minx+1):
    f = 1
    while True:
        if i**f > n:
            ans = max(ans,i**(f-1))
            break
        f+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

li=[]
for i in range(1,int(1000**0.5)+1):
  for j in range(2,11):
    tmp=i**j
    if tmp>1000:
      break
    else:
      li.append(tmp)
l=(sorted(set(li)))
x=int(input())
#l=[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]
ans=0
for i in l[::-1]:
  if i<=x:
    print(i)
    exit()

Submission status: Accepted

Solution code:
x = int(input())

if x ==1:
    print(1)

else:
    flag = False
    for i in range(x):
        for k in range(x-1):
            for j in range(2, 10):
                if x-i == (k+1)**j:
                    flag = True
                    print(x-i)
                    break
            if flag:
                break
        if flag:
            break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from math import floor, sqrt, log

x = int(sys.stdin.readline().rstrip())

def main():
    res = [1]
    for b in range(2, x+1):
        p = 2
        while b ** p <= x:
            res.append(b ** p)
            p += 1
    return max(res)

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

Submission status: Accepted

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

for b in range(2,int(x**0.5//1)+1):
    a = b
    p = 1
    while a <= x:
        a *= b
        p += 1
    else:
        ans = max(b**(p-1),ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

x = int(input())
x_rt = int(math.sqrt(x))

arr = [1]
for i in range(2, x_rt + 1):
    bas = i
    while bas * i <= x:
        bas *= i
        arr.append(bas)

ans = max(arr)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0

if x == 1:

 print(1)

 exit()

for i in range(2, 51):

 tmp = i

 while tmp * i < x + 1:

  tmp = tmp * i

  ans = max(ans, tmp)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
minsa=1000
for a in range(1,32):
  for b in range(2,10):
    l=a**b
    sa=n-l
    if sa>=0:
      minsa=min(sa,minsa)
print(n-minsa)

Submission status: Accepted

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

x = int(input())

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

ans = [i for i in kk if (i <= x)]
print(ans[-1])

Submission status: Accepted

Solution code:
n = int(input())
l = []
if n == 1:
    print(1)
else:
    for i in range(1, n + 1):
        for j in range(2, n + 1):
            if i ** j > n:
                break
            l.append(i ** j)
    l = list(set(l))
    l = sorted(l)
    ans = 0
    for i in range(len(l)):
        if l[i] > n:
            break
        ans = l[i]
    print(ans)

Submission status: Accepted

Solution code:
x = int(input())
 
m = 1
 
for i in range(1, 32):
    for j in range(2, 10):
        p = pow(i, j)
        if p > x:
            break
        if p > m:
            m = p
 
print(m)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    candidates = [1]
    c_append = candidates.append
    max_range = int(X**0.5) + 1
    for i in range(2, max_range):
        for j in range(2, max_range):
            powered = i ** j
            if powered > X:
                break
            else:
                c_append(powered)
    ans = max(candidates)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
X = int(input())
if X == 1:
    print(1)
else:
    maxa = 0
    for i in range(2,32):
        for j in range(2,11):
            if i**j <= X:
                maxa = max(maxa,i**j)
    print(maxa)

Submission status: Accepted

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

for i in range(2, 34):
  count = 2
  
  while i ** count <= n:
    m = max(m, i**count)
    count += 1
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
num = []
for b in range(1,x):
    for p in range(2,11):
        num.append(b**p)
num.sort(reverse = True)
for val in num:
    if val <=x:
        print(val)
        break
if x ==1:
    print(1)

Submission status: Accepted

Solution code:
from math import sqrt

X = int(input())

result = 1
for i in range(2, int(sqrt(X)) + 1):
    t = i * i
    while t <= X:
        if t > result:
            result = t
        t *= i
print(result)

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

x = int(input())

pows = [1]
for i in range(2, x+1):
	p = 2
	while i**p <= x:
		pows.append(i**p)
		p+=1
pows.sort()

print(pows[bisect.bisect(pows, x)-1])

Submission status: Accepted

Solution code:
import math
X = int(input())
ans = 0
for i in range(1,int(math.sqrt(X))+1):
    for k in range(1,int(math.sqrt(X))+1):
        if ans < i**k <= X:
            ans = i**k
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):
    x = i ** j
    if x <= X:
      ans = max(i ** j,ans)
    if x > X:
      break
      

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
x=int(input())
ans=[1]
for i in range(2,x+1):
    #print(i)
    k=int(math.log(x,i))
    if k>=2:
        if i**(k+1) <= x:
            ans.append(i**(k+1))
        else:
            ans.append(i**k)
print(max(ans))
#print(ans)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
for b in range(int(x**0.5 + 1)):
    for q in range(20):
        if b ** q > x:
            break
        ans = max(ans, b**q)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for b in range(2, x+1):
    _x = b*b
    while _x <= x:
        ans = max(ans, _x)
        _x *= b

print(ans)

Submission status: Accepted

Solution code:
import math
x = int(input())
exp = set()
# for i in range(x,0,-1):
#   if math.sqrt(i).is_integer():
#     print(i)
#     break
for b in range(1,x + 1):
  for p in range(2,int(math.log2(x)) + 1):
    if b ** p <= x:
      exp.add(b ** p)
if len(exp) == 0:
  print(1)
else:
  print(max(exp))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(X: int):
    ans = 0
    for b in range(1, 32):
        for p in range(2, 10):
            bp = b**p
            if bp > X:
                pass
            else:
                ans = max(ans, bp)

    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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 sys
X = int(input())

if X == 1:
    print(1)
    sys.exit(0)

ans = 0
for b in range(1, 31+1):
    for p in range(2, 31+1):
        bp = b**p
        if ans <= bp and bp <= X:
            ans = bp

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
ceil = 1000
X = int(input())
ans = 1
for p in range(2, 11):
  for b in range(2, int(math.sqrt(ceil))+1):
    tmp = b ** p
    if tmp > X: break
    else: ans = max(tmp, ans)
    
print(ans)

Submission status: Accepted

Solution code:
import math
ceil = 1000
X = int(input())
ans = 1
for p in range(2, 11):
  for b in range(2, int(math.sqrt(ceil))+1):
    tmp = b ** p
    if tmp > X: break
    if tmp > ans: ans = tmp
    
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

l = [1]
for b in range(2, 32):
    p = 2
    while b ** p <= 1000:
        l.append(b ** p)
        p += 1
l.sort()
l.append(10**5)

for i in range(len(l)):
    if l[i] > x:
        print(l[i-1])
        exit()
print(l)

Submission status: Accepted

Solution code:
#lst = [int(i) for i in input().split()]
x = int(input())
m = 1
for i in range(2, 10):
    tmp = int(x ** (1 / i) + 0.00001) ** i
    if x >= tmp > m:
        m = tmp
print(m)

Submission status: Accepted

Solution code:
X = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
#97b
X = int(input())

#X <= 1000より最大は10^3
#maxは31^2
#minは2^9
ans = 1

for b in range(1,32):
    for p in range(2,9):
        if b**p > ans and b**p <= X:
            ans = b**p
            
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
res=[]

res.append(1)

for i in range(2,33):
  for j in range(1,10):
    if N < i**j:
      if j-2!=0:
        res.append(i**(j-1))
      break
print(max(res))

Submission status: Accepted

Solution code:
ls=[1,2,4,8,16,32,64,128,256,512,3,9,27,81,243,729,
    25,125,625,36,216,49,343,100,1000,
   121,144,169,196,225,289,324,361,400,
   441,484,529,576,625,676,781,841,900,961,1001]
ls.sort()
n=int(input())
for i in range(len(ls)):
  if ls[i]>n:
    print(ls[i-1])
    break

Submission status: Accepted

Solution code:
x = int(input())

number = [i for i in range(1,34)]
beki = []
for i in number:
    for j in range(2,11):
        if i ** j <= x:
            beki.append(i**j)
ans = max(beki)
print(ans)

Submission status: Accepted

Solution code:
import math as m
X = int(input())
end = m.floor(m.sqrt(X))
ans = 1
for i in range(2, end+1):
    now = i
    while now * i <= X:
        ans = max(ans, now* i)
        now *= i
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0

for i in range(1, 35):
    for j in range(2, 11):
        if 0 <= x - i**j < x - ans:
            ans = i**j        

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

ans = 1

for b in range(32,0, -1):
    for p in range(2,11):
        if b**p <= x and ans <= b**p:
            ans = b**p

print(ans)

Submission status: Accepted

Solution code:
X=int(input())

m,c=1,2
while c*c<=X:
	i=2
	while c**i<=X:
		m=max(m,c**i)
		i+=1
	c+=1
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
if X != 1:
  A =[]
  for b in range(1,int(X**0.5)+1):
    for p in range(2,X):
      if b**p > X:
        A.append(b**(p-1))
        break
  print(max(A))
else:
  print(1)

Submission status: Accepted

Solution code:
X =int(input())

A = [1]
for i in range(1, 50):
    for j in range(2, 50):
        if i**j <= X:
            A.append(i**j)
print(max(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(1000):
  for j in range(2,20):
    if i**j > n:
      break
    ans = max(ans, i**j)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

l = [1]

for i in range(2, 32):
    a = i
    while a*i <= 1000:
        a *= i
        l.append(a)

l.sort(reverse=True)

for c in l:
    if c <= x:
        print(c)
        exit()

Submission status: Accepted

Solution code:
N = int(input())
ans = 1000
ans2 = 0
for i in range(1000):
  for j in range(2,10):
    if N - i**j < 0:
      break
    if ans > N - i ** j:
      ans = N - i**j
      ans2 = i**j
print(ans2)

Submission status: Accepted

Solution code:
x = int(input())

exp = [1]
for b in range(2, 32):
    for p in range(2, 10):
        beki = b**p
        if beki <= 1000:
            exp.append(beki)
        else:
            break

exp.sort()
for e in exp:
    if e > x:
        break
    ans = e
else:
    ans = 1000

print(ans)

Submission status: Accepted

Solution code:
A = int(input())
m = 0
for i in range(2,10):
  for j in range(40):
    k = j ** i 
    if A >= k:
      m = max(m,j**i)
print(m)

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for i in range(2, X + 1):
    y = i * i
    while y < X: y *= i
    if X < y: y //= i
    if y != i: ans = max(ans, y)
print(ans)

Submission status: Accepted

Solution code:
def pff(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1: pf[m] = 1
    return pf
def examB():
    X = I()
    ans = 0
    for i in range(X,0,-1):
        cur = pff(i)
        flag = True
        now = 0
        for j in cur.values():
            if j==1:
                flag = False
            if now==0:
                now = j
            else:
                if now%j!=0 and j%now!=0:
                    flag = False
        if flag:
            ans = i
            break
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()