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:
#!/usr/bin/env python
# coding: utf-8

# In[20]:


X = int(input())


# In[22]:


for i in range(X+1)[::-1]:
    for j in range(2,i):
        p = 2
        flag = False
        while flag == False:
            if j**p == i:
                print(i)
                flag = True
                break
            elif j**p > i:
                break
            else:
                p += 1
        if flag:
            break
    else:
        continue
    break
else:
    print(1)


# In[ ]:

Submission status: Accepted

Solution code:
x = int(input())
A = [a**b for a in range(1, 35) for b in range(2, 10) if a**b <= x]
A.sort()
print(A[-1])

Submission status: Accepted

Solution code:
s=set()
s.add(1)
x=1001
for i in range(2,1000):
    k=i*i
    while k<x:
        s.add(k)
        k*=i
#print(sorted(s))
l=[i for i in range(1001)]
for i in range(1,1001):
    if i in s:
        l[i]=i
    else:
        l[i]=l[i-1]
print(l[int(input())])

Submission status: Accepted

Solution code:
A=int(input())
B=[1]*8
for i in range(2,10):
  for j in range(A+1):
    if j**i <= A:
      B[i-2]= j**i
    else:break
print(max(B))

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:
def resolve():
    X = int(input())
    ans = 1
    for b in range(1000 + 1, 1, -1):
        for p in range(2, 10 + 1):
            if b ** p <= X:
                ans = max(ans, b ** p)
    print(ans)


resolve()

Submission status: Accepted

Solution code:
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    X = ii()
    l = []
    for b in range(1, 1001):
        if b == 1:
            l.append(1)
            continue
        a = b*b
        while a <= X:
            l.append(a)
            a *= b
    print(max(l))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
from math import sqrt
X = int(input())
N = int(sqrt(X))
ans = N**2
for i in range(N,0,-1):
  for j in range(X):
    if abs(X-i**j) < abs(X-ans) and i**j <= X:
      ans = i**j

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
for i in range(1,32):
    for p in range(2,10):
        y = i**p
        if y > 1000:
            break
        if ans < y <= x:
            ans = y
print(ans)

Submission status: Accepted

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

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

    b = 1
    p = 2

    a = []

    for i in range(int(x ** 0.5) + 1):
        for j in range(int(x ** 0.5) + 1):
            if (b+i) ** (p+j) <= x:
                a.append((b+i) ** (p+j))

    print(max(a))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X=int(input())
check=[False]*(X+1)
check[1]=True
for i in range(2,X+1):
  temp=i*i
  while temp<=X:
    check[temp]=True
    temp*=i
for i in range(X,0,-1):
    if check[i]==True:
      print(i)
      exit()

Submission status: Accepted

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

s = math.floor(math.sqrt(x))

def l(k,p):
  q = int(math.floor(math.log(p)/math.log(k)))
  if k ** (1+q) <= p:
    return(1+q)
  else:
    return(q)

ans = 0
for i in range(2,s+1):
  ans = max(ans, i ** l(i,x))
  if ans == x:
    print(x)
    exit()
  
print(ans)

Submission status: Accepted

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

s = math.floor(math.sqrt(x))

def l(k,p):
    return(int(math.floor(math.log(p)/math.log(k))))

ans = 0
for i in range(2,s+1):
  if i ** (1 + l(i,x)) <= x:
    ans = max(ans, i ** (1+l(i,x)))
  else:
    ans = max(ans, i ** l(i,x))
  if ans == x:
    print(x)
    exit()
  
print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_right

x = int(input())
l = []

for i in range(2, 10):
    j = 1
    while j ** i <= 1000:
        y = j ** i
        if y not in l:
            l.append(y)
        j += 1

l.sort()
print(l[bisect_right(l, x)-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
hantei=1
for i in range(2,33):
  jou=2
  while i**jou<=x:
    if hantei< i**jou:
      hantei=i**jou
    jou+=1
print(hantei)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

if __name__ == '__main__':
    n =int(input())
    a = int(math.sqrt(n))

    max=1
    for i in range(2,a+1):
        now = i*i
        while now <= n:
            if max < now:
                max =now
            now = now*i
    print(max)

Submission status: Accepted

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

if x==1:
    print(1)

else:

    for i in range(2,x+1):
        for j in range(1,x+1):
            y=j**i
            if y<=x:
                l.append(y)
            elif y>x:
                break
    print(max(l))

Submission status: Accepted

Solution code:
import math

X = int(input())
ans = 1
flg = False
for i in range(X, 0, -1):
    if flg:
        break
    for j in range(2, int(math.sqrt(i)) + 1):
        temp = i
        while True:
            if temp % j != 0:
                break
            elif temp / j == 1:
                print(i)
                flg = True
            temp = temp // j
        if flg:
            break
if not flg:
    print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

max_ = 1
for i in range(2, n):
  k = i
  c = 1
  while k <= n:
    k *= i
    c += 1
  if c > 2:
    max_ = max(max_, k//i)
print(max_)

Submission status: Accepted

Solution code:
x = int(input())

ans = []
if x == 1:
  print(1)
  exit()

for i in range(2,x+1):
  for j in range(2,x+1):
    if i**j > x:
      break
    ans.append(i**j)

if len(ans)==0:
  print(0)
else:
  print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for b in range(1, 32): # 1000**0.5より31
    for p in range(2, 10): # log2(1000)より9
        tmp = b**p
        if tmp <= x and tmp >= ans:
            ans = tmp
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X = ir()
answer = 1
for y in range(2, X):
    temp = y * y
    if temp > X:
        continue
    while temp * y <= X:
        temp *= y
    if temp > answer:
        answer = temp

print(answer)

Submission status: Accepted

Solution code:
X = int(input())

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

for i in range(101):
    if dammy[i]>X:
        print(dammy[i-1])
        break

Submission status: Accepted

Solution code:
X = int(input())
count = [1]
for x in range (2,50):
    for y in range (2,10):
        if x ** y <= X:
            count.append(x ** y)
print(max(count))

Submission status: Accepted

Solution code:
x=int(input())

s=set([1])

for b in range(2,x):
  for p in range(2,11):
    if b**p>x:
      break
    s.add(b**p)
print(max(s))

Submission status: Accepted

Solution code:
X = int(input())

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

ans = [False] * (X + 1)
for i in range(2, X + 1):
    v = i * i
    while v <= X:
        ans[v] = True
        v *= i

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
x=int(input())
lis=[1]
for i in range(2,math.ceil(math.sqrt(x))):
  n=i*i
  while n<=x:
    lis.append(n)
    n*=i

print(max(lis))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
x = int(input())
ans = 0
for i in range(1, x+1):
    for j in range(2, x+2):
        if pow(i, j) <= x:
            ans = max(pow(i, j), ans)
        else:
            break
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:
import math
f= False

x=int(input())
for i in range(x):
	for j in range(1, 1+int(math.sqrt(x))):
		for k in range(2,10):
			if x == j**k:
				print(x)
				f=True
				break
		if f:
			break
	if f:
		break
	x-=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

def primes(x):
    res = []
    a = 2
    while x >= a*a:
        while x % a == 0:
            x //= a
            res.append(a)
        a += 1
    if x != 1:
        res.append(x)
    return res

x = int(input())
if x < 4:
    print(1)
else:
    for i in reversed(range(2,x+1)):
        p = primes(i)
        ctr = collections.Counter(p)
        cnt = ctr[p[0]]
        if cnt >= 2 and all([cnt == v for v in ctr.values()]):
            print(i)
            break

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

x = ni()

num = 1

for i in range(100):
  for j in range(2,10):
    if i**j <= x:
      num = max(num,i**j)

print(num)

Submission status: Accepted

Solution code:
import math
x = int(input())
ans = 1 # 1^b = 1
n = math.floor(math.sqrt(x))
for i in range(2, n+1): # [2,n]
    a = i # a^1
    while a < x:
        a *= i # a^b,(b>=2)
        if a <= x: ans = max(ans, a)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

tmp = 2
ans = 1

while tmp*tmp <= x:
    cur = tmp*tmp
    while cur*tmp <= x:
        cur *= tmp
    ans = max(ans, cur)
    tmp += 1

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1 # 1^b = 1
for i in range(2, x+1): # [2,x]
    a = i # a^1
    while a < x:
        a *= i # a^b,(b>=2)
        if a <= x: ans = max(ans, a)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
if x < 4:
    print(1)
    exit()
ans = 1 # 1^b = 1
for i in range(2, x+1): # [2,x]
    a = i # a^1
    while a < x:
        a *= i # a^b,(b>=2)
        if a <= x: ans = max(ans, a)
print(ans)

Submission status: Accepted

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

ans = 1 # 1^b = 1
for i in range(2, x+1): # [2,x]
    a = i # a^1
    while a < x:
        a *= i # a^b,(b>=2)
        if a <= x: ans = max(ans, a)
print(ans)

Submission status: Accepted

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

L = []
for i in range(2,int(math.floor(math.sqrt(x)))+1):
  for j in range(x//i + 1):
    if i ** j <= x:
      L.append(i ** j)
      
if L == []:
  print("1")
else:
  print(max(L))

Submission status: Accepted

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

ans = [1]
limit = int(math.sqrt(X))
for i in range(2, limit+1):
    p = 2
    while i ** p <= X:
        ans.append(i ** p)
        p += 1

print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
nums = [125,216,343,1000]
for i in range(n,0,-1):
    if i in nums:
        print(i)
        sys.exit()
    if ((i**(1/2))%1 == 0) or ((i **(1/3))%1 == 0) or  ((i **(1/5))%1 == 0) or ((i **(1/7))%1 == 0) or ((i **(1/9))%1 == 0):
        print(i)
        sys.exit()
print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
for b in range(1, 1001):
    for n in range(2, 10):
        a = b ** n
        if a <= x:
            ans = max(ans, a)
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
nums = set([1])
for i in range(2, int(1000 ** .5) +1):
    b = 2
    while True:
        temp = i ** b
        if temp > 1000:
            break
        nums.add(temp)
        b += 1
sorted_nums = sorted(list(nums), reverse=True)
# print(f"nums:{sorted_nums}", file=sys.stderr)
if X >= sorted_nums[0]:
    print(sorted_nums[0])
else:
    for i in range(len(sorted_nums) - 1):
        if sorted_nums[i] > X >= sorted_nums[i + 1]:
            print(sorted_nums[i + 1])

Submission status: Accepted

Solution code:
X = int(input())

ans = 0



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

print(ans)

Submission status: Accepted

Solution code:
x=int(input())
i=1
mx=i
while(i**2<x):
  i+=1
  j=2
  while(i**j<=x):
    j+=1
  if i**(j-1)>mx:
    mx=i**(j-1)
print(mx)

Submission status: Accepted

Solution code:
from math import ceil
def main():
    x = int(input())
    r = 0
    for i1 in range(1, ceil(x**0.5) + 1):
        beki = 2
        while True:
            num = pow(i1, beki)
            if num <= x:
                r = max(r, num)
            else:
                break
            if num == pow(i1, beki - 1):
                break
            beki += 1

    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = int(input())

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
x = int(input())

ans = 0

for a in range(1, 32):
    for b in range(2, 10):
        if x >= a ** b:
            ans = max(ans, a**b)

print(ans)

Submission status: Accepted

Solution code:
X=int(input())
a_max=1
for b in range(2,X//2):
  a=1
  p=2
  while a<X:
    a=b**p
    p+=1
    if X >= a > a_max:
      a_max=a
print(a_max)

Submission status: Accepted

Solution code:
X=int(input())
a=1
b=2
p=2
while b<=int(X**.5):
    if b**p<=X:
        a=max(a,b**p)
        p+=1
    else:
        b+=1
        p=2
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
X=int(input())
x=math.floor(math.sqrt(X))
l=list()
for i in range(1,x+1):
  for n in range(1,7):
    if i**n<=X and i**(n+1)>=X:
      l.append(i**n)

print(max(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    L = [False]*1001
    for i in range(1,41):
        for j in range(2,11):
            temp = i**j
            if temp > X:
                break
            L[temp] = True
    m = 0
    for i in range(X+1):
        if L[i]:
            m = i
    print(m)





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=input()
l=len(n)
n=int(n)
ans=0
for i in range(2,7*l):
    t=int(n**(1/i))
    for j in range(3):
        if (t+j)**i<=n:
            ans=max((t+j)**i,ans)
print(ans)

Submission status: Accepted

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

expotential_set = set()
for i in range(1, 1000):
    for j in range(2, 10):
        expotential_set.add(pow(i, j))

expotential_list = sorted(list(expotential_set))

distance = 10000000000000
for num in expotential_list:
    if num <= x and abs(num - x) < distance:
        distance = abs(num - x)
        ans = num

print(ans)

Submission status: Accepted

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

    ans = 1
    for i in range(2, 11):
        for j in range(32):
            if j ** i <= X:
                if j ** i > ans:
                    ans = j ** i

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

l = [1]

for i in range(2, int(x ** 0.5)+1):
    t = 2
    while True:
        if i ** t <= x:
            l.append(i ** t)
            t += 1
        else:
            break

l.sort()

print(l[-1])

Submission status: Accepted

Solution code:
X = int(input())
ans = {1}
for i in range(2, 40):
    y = 2
    while i ** y <= X:
        ans.add(i ** y)
        y += 1
print(sorted(list(ans))[-1])

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
x = int(input())

A = [1]
for i in range(x+1):
    for j in range(2,x+1):
        if i**j <= x and i**j not in A:
            A.append(i**j)
        if i**j > x:
            break

print(max(A))

Submission status: Accepted

Solution code:
X = int(input())

ans = 1

for i in range(1, 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:
import bisect
x = int(input())
ex = [1]

for b in range(2, 32):
  for p in range(2, 10):
    if b**p <= 1000:
      ex.append(b**p)
    else:
      break
      
ex.sort()
r = bisect.bisect_right(ex, x)
    
print(ex[r-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
S = set()
S.add(1)
for b in range(2, int(1000**0.5) + 1):
	for p in range(2, 10):
		if b**p > 1000:
			break
		S.add(b**p)
for n in range(x, 0, -1):
	if n in S:
		print(n)
		exit()

Submission status: Accepted

Solution code:
X = int(input())
c = {i ** j for i in range(34) for j in range(2, 11) if i ** j <= 1000}
print(max([i for i in c if i <= X]))

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,1000):
    for j in range(2,10):
        n = i**j
        if n <= x:
            ans = max(ans,n)
print(ans)

Submission status: Accepted

Solution code:
import bisect
x=int(input())
a=[1]
b=2
i=2
while b<=997:
    while b**i<=1000:
        a.append(b**i)
        i+=1
    b+=1
    i=2
a=sorted(list(set(a)))
print(a[bisect.bisect(a,x)-1])

Submission status: Accepted

Solution code:
x=int(input())
ans=0
num=x+100
for i in range(1,33):
    for j in range(2,11):
        a=x-(i**j)
        if a>=0 and num>a:
            ans=x-a
            num=a
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for i in range(1,int(x**0.5)+1):
    for j in range(2,x//2 + 1):
        if x >= i**j:
            ans = max(i**j, ans)


print(ans)

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    x = ii()
    L = [False] * (x+1)
    L[1] = True
    for i in range(2, 32):
        for j in range(2, 10):
            if pow(i, j) <= x:
                L[pow(i, j)] = True
    # print(L)
    for num in range(x, 0, -1):
        if L[num]:
            print(num)
            exit()



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
X = int(input())
val = 1
for b in range(1, int(X**0.5)+1):
    for p in range(2,X):
        if b**p > X:
            break
        else:
            val = max(val, b**p)
print(val)

Submission status: Accepted

Solution code:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


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

Submission status: Accepted

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

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
l=[0]*(x+1)

if x==1:
    print(1)
    exit()
    
for i in range(1,x):
    for j in range(2,1000):
        if i**j>x:
            break
        l[i**j]=1

for i in reversed(range(x+1)):
    if l[i]==1:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
if x == 1000:
    print(1000)
else :
    for _ in range(1000):
        if all(x**(1/i)!=int(x**(1/i)) for i in range(2, 100)):
            x -= 1
        else :
            print(x)
            break

Submission status: Accepted

Solution code:
N = int(input())
X = set()
for i in range(1,32):
  for j in range(2, 10):
    if pow(i,j) <= N:
      X.add(pow(i, j))
    else:
      break
print(max(X))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
n = set()
n.add(1)
for i in range(2,33):
    a = i
    beki = 2
    while a**beki <= x:
        n.add(a**beki)
        beki += 1
        if a**beki > x:
            break

print(max(n))

Submission status: Accepted

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