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())

import math
def is_beki(n):
  for i in range(2, int(math.sqrt(n)//1)+1):
    beki = i
    while beki <= n:
      if beki == n:
        return True
      beki = beki * i
  return False

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def main():
    X = int(input())
    ans = 1
    for b in range(X, 0, -1):
        for p in range(10, 1, -1):
            if b ** p <= X:
                ans = max(ans, b ** p)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

li = [1]

for i in range(2,33):
	SUM = i
	while SUM <= 1000:
		SUM *= i
		li.append(SUM)

li = list(set(li))
li.sort()

N = int(input())
ind = bisect.bisect_right(li,N)
print(li[ind-1])

Submission status: Accepted

Solution code:
x = int(input())
out = 1
for i in range(2,33):
    for j in range(2,10):
        num = i**j
        if x >= num:
            out = max(out, num)
print(out)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
 
ans = 1
p = 2
A = set()
for i in range(2,X):
  if(i in A):
    continue
  p = 1
  while(True):
    p += 1
    power = i ** p
    if(power <= X):
      A.add(power)
      tmp = power
      pass
    else:
      break
  if(ans<tmp):
    ans = tmp
  if(p == 2):
    break
  
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
ans = set([1])
for a in range(2,32):
    b = a
    while b*a <= X:
        b *= a
        ans.add(b)
print(max(ans))

Submission status: Accepted

Solution code:
from math import sqrt

X = int(input())

ans_cand = [1]
for n in range(2,int(sqrt(X)+1)):
    res = n
    while res*n <= X:
        res *= n
        
    ans_cand.append(res)
    
print(max(ans_cand))

Submission status: Accepted

Solution code:
x = int(input())

for x_i in range(x, 0, -1):
    for j in range(2, max(3, x_i)):
        n = 0
        while n**j < x_i:
            n += 1
        if n**j == x_i:
            print(x_i)
            exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
for i in range(x,0,-1):
    for p in range(1,int(i**.5)+1):
        for q in range(10):
            if i==p**q:
                print(i)
                break
        else:
            continue
        break
    else:
        continue
    break

Submission status: Accepted

Solution code:
import sys
x = int(input())
lis = [1,4,8,16,32,64,128,256,512,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,676,784,841,900,961]
lis.sort(reverse=True)
for nums in lis:
  if nums <= x:
    print(nums)
    sys.exit()

Submission status: Accepted

Solution code:
n=int(input())
s=set()
for i in range(1000):
    s=s|{i**j for j in range(2,10) if i**j<=1000}
l=sorted(s)
for (i,j) in enumerate(l):
    if n<j:
       print(l[i-1])
       break;
    elif n==j:
        print(n)
        break;

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys 
import math

X = int(input())
#a = list(map(int, input().split(" ")))
a = [0 for i in range(X+1)]

a[1] = 1

for i in range(2,int(math.sqrt(X))+1):
    num = i*i
    while num <= X:
        a[num]=1
        num *= i

for i in range(1,X+1):
    if a[i] == 1:
        ans = i
print(ans)

Submission status: Accepted

Solution code:
#coding:utf-8
x = int(input())
ans = 1
i = 2
minv = 100000
while i ** 2 <= x:
    n = 2
    while i ** n <= x:
        if minv > x - i ** n:
            minv = min(minv, x - i ** n)
            ans = i ** n
        n += 1
    i += 1
print(ans)

Submission status: Accepted

Solution code:
#標準入力
X = int(input())

max_beki = 1
for i in range(1,X):
  for j in range(2,X):
    beki = i ** j
    
    if beki > X:
      break
      
    elif beki > max_beki:
      max_beki = beki
 
print(max_beki)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
list1=[]
for b in range(1,33):
    for p in range(2,11):
        if b**p not in list1 and b**p<=1000:
            list1.append(b**p)
        elif b**p>1000:
            break
list1.sort()
N=int(input())
ans=0
for i in range(len(list1)):
    if list1[i]<=N:
        ans=list1[i]
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
import math
N=int(input())
def beki(x):
    b=2
    while b <= math.sqrt(x):
        p=2
        while b**p <=x:
            if b**p == x:
                return True
                break
            else:
                p+=1
        else:
            b+=1
    else:
        return False
while N>=2:
    if beki(N)==True:
        print(N)
        break
    else:
        N-=1
else:
    print(1)

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

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

    A = [1]
    for a in range(2, 100):
        for b in range(2, 10000):
            if a ** b <= 1000:
                A.append(a ** b)
            else:
                break

    print(sorted(filter(lambda a: a<=x, A))[-1])



main()

Submission status: Accepted

Solution code:
x = int(input())
exp_set = set()
exp_set.add(1)
for i in range(2, 32):
  p = 2
  while True:
    if i**p > 1000:
      break
    exp_set.add(i**p)
    p += 1
ans = 0
for ele in sorted(list(exp_set)):
  if ele > x:
    break
  ans = ele
print(ans)

Submission status: Accepted

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

def main():
    #入力
    X = int(input())

    exp_list = [1]
    i = 2
    flag = 0

    while True:
        j = 2
        while True:
            if i ** j <= X:
                exp_list.append(i ** j)
                j += 1
            elif i ** 2 > X:
                flag = 1
                break
            else:
                break
        i += 1
        if flag == 1:
            break
    
    print(max(exp_list))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import sqrt

x = int(input())
xr = int(sqrt(x))

l=[1]
for i in range(1,xr+1):
    t=[]
    for j in range(2,xr):
        if i**j <= x:
            t.append(i**j)
        else:
            break
    l = l+t
l = list(set(l))
l.sort()


left=0
right=len(l)
center=0

while left < right:
    center = (left+right)//2
    if l[center] == x:
        break
    elif l[center] < x:
        left = center+1
    else:
        right = center

print(l[center])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
k = [[0], [0], [i*i for i in range(32) if i*i <= x]]
i = 2
while(len(k[i]) > 2):
  k.append([k[i][j]*j for j in range(len(k[i])) if k[i][j]*j <= x])
  i += 1
print(max([l[-1] for l in k]))

Submission status: Accepted

Solution code:
import math
X = int(input())
b_list = []
for b in range(1,int(math.sqrt(X))+1):
    for p in range(2,11):
        if b**p <=X:
            b_list.append(b**p)
print(max(b_list))

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
if X > 1:
  for b in range(1, 32):
    for p in range(2, 11):
      if ans <= X and pow(b, p) <= X:
      	ans = max(ans, pow(b, p))
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

rtn = 0 
if X == 1:
    print(X)
else:
    for i in range(2,X//2):
        j = 2 
        while(True):
            tmp = i ** j
            if(tmp > X): 
                break 
            elif(tmp > rtn):
                rtn = tmp 
            j+=1
    print(rtn)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())
power=[i for i in range(2,10)]
max_pow=0
for j in range(1,X+1):
    for pow_number in power:
        if pow(j, pow_number)<=X:
            max_pow=max(pow(j, pow_number), max_pow)
print(max_pow)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())

a=1
while a**2<=x:
    a+=1
b=1
while b**3<=x:
    b+=1
ans=max((a-1)**2,(b-1)**3)
if 32<=x:
    ans=max(ans,32)
if 243<=x:
    ans=max(ans,243)
if 128<=x:
    ans=max(ans,128)
print(ans)

Submission status: Accepted

Solution code:
def beki(n,X):
    # the maximum of the form n**k under X
    x = 1
    while x*n <= X:
        x *= n
    if x == n:
        return 1
    else:
        return(x)

X = int(input())
a = 1

for n in range(X)[2:]:
    b = beki(n,X)
    if b > a:
        a = b

print(a)

Submission status: Accepted

Solution code:
x=int(input())
def beki(n):
    for i in range(2,32):
        k=n
        if k%i==0:
            t=0
            while k>=1:
                k/=i
                if k==1 and t>=1:
                    return True
                t+=1
y=1
for i in range (1,x+1):
    if beki(i)==True:
        y=i
print(y)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    X = int(input())

    if X == 1:
        print(1)
    else:
        res = 0
        for i in range(2, X):
            p = 2
            while True:
                temp = i ** p
                if temp <= X:
                    if res < temp:
                        res = temp
                    else:
                        p += 1
                else:
                    break
        print(res)

Submission status: Accepted

Solution code:

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

    ns = []
    for i in range(1, 33):
        for j in range(2, 10):
            ns.append(i ** j)

    ns = list(set(ns))
    ns.sort()

    for i, n in enumerate(ns):
        if x < n:
            print(ns[i-1])
            return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())
num = [1]
for i in range(2,X):
  temp = i
  while temp*i<=X:
    temp=temp*i
    num.append(temp)
    
print(sorted(num)[-1])

Submission status: Accepted

Solution code:
X = int(input())

beki = 0
for p in range(2, 9):
    tmp = 0
    b = 1
    while tmp <= X:
        tmp = b**p
        if tmp > X:
            break
        beki = max(tmp, beki)
        b += 1

print(beki)

Submission status: Accepted

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

answer=1

for i in range(2,int(math.sqrt(X))+1):
 j=2
 while i**j<=X:
  answer=max(answer,i**j)
  j+=1

print(answer)

Submission status: Accepted

Solution code:
import math
x = int(input())
lis = [1]
for i in range(2, int(math.sqrt(x))+1):
    j = 2
    sample = 0
    while i ** j <= x:
        sample = i ** j
        j += 1
    if sample != 0:
        lis.append(sample)
print(max(lis))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(x):
  s = set()
  s.add(1)
  for b in xrange(2, x+1):
    y = b
    for p in xrange(x+1):
      y *= b
      if y > x: break
      s.add(y)
  l = sorted(list(s))
  return l[-1]
  
X=int(raw_input())
print f(X)

Submission status: Accepted

Solution code:
x=int(input())
result = [1]

for i in range(2, x):
    sum = i
    while sum * i <= x:
        sum = sum * i
        result.append(sum)

print(sorted(result)[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

X = int(input())

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
import math

X = int(input())

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
import math

X = int(input())

ans = 1
for i in range(X+1):
  for j in range(2,max(math.floor(math.sqrt(X-i))+1,3)):
    beki = False
    tmp = X-i
    while True:
      if tmp%j != 0:
        if tmp == 1:
          beki = True
        break
      else:
        tmp //= j
    if beki:
      ans = X-i
      break
  if beki:
    break

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:
            ans=max(ans, i**j)
print(ans)

Submission status: Accepted

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

def solve(X):
	ans = X
	# b^p = ansとなるansを探す
	for b in range(2, X):
		p = math.log(ans, b) # 精度で死ぬ(log(100, 10)など)
		if float.is_integer(p):
			return ans
	return 1

def solve2(X):
	# 全探索
	for x in range(X, 1, -1):
		for p in range(2, x):
			for b in range(2, x):
				bp = b**p
				if bp == x:
					return x
				if bp >= x:
					break
	return 1

if __name__ == "__main__":
	X = int(input())
	print(solve2(X))

Submission status: Accepted

Solution code:
import math

x = int(input())

max_pow = 1
for i in range(1, math.ceil(math.sqrt(x))):
    for p in range(2, 9):
        i_p = i**p
        if i_p > x:  break
        if i_p > max_pow: max_pow = i_p
            
print(max_pow)

Submission status: Accepted

Solution code:
import math
X = int(input())
# maximum base b comes with minimum power p = 2, b**2 <= X
max_base = int(X**(1.0/2.0))
# maximum power p comes with minimum base b = 1, no limit. next min: b = 2
max_power = int(math.log(X)/math.log(2))
perfect_powers = [b**p for p in range(2,max_power+1) for b in range(1,max_base+1) if b**p <= X]
if perfect_powers:
    print(max(perfect_powers))
else: 
    print(1)

Submission status: Accepted

Solution code:
X, = map(int,raw_input().split())
m = 0
for b in range(1,100):
  for p in range(2,11):
    if b**p <= X:
      m = max(m, b**p)
print m

Submission status: Accepted

Solution code:
x = int(input())
if x != 1:
  a = []
  for i in range(2,34):
      n = i**2
      while n <= x:
          a.append(n)
          n = n*i

  print(max(a))
else:
  print(1)

Submission status: Accepted

Solution code:
X = int(input())

powers = {1}

for p in range(2, 32):
    pw = p*p
    while pw <= X:
        powers.add(pw)
        pw *= p

print(max(powers))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
res = 1
for i in range(1,n+1):
    for k in range(2,1+n):
        num = i**k
        if num > n:
            break
        if num <= n :
            res = max(res,num)
    
print(res)

Submission status: Accepted

Solution code:
X = int(input())

num = 0
for i in range(1, X + 1):
    if i**2 < X:
        num = i

ans = 1
for i in range(1, num + 1):
    for j in range(2, num + 1):
        x = i**j
        if x > X:
            break

        if ans < x:
            ans = x

print(ans)

Submission status: Accepted

Solution code:
X = int(input())

a = 1
b = 2
while b**2 <= X:
  p = 2
  while b**p <= X:
    a = max(a, b**p)
    p += 1
  b += 1
print(a)

Submission status: Accepted

Solution code:
X = int(input())
x_max=0
if X==1:
    x_max=1
elif X==2:
    x_max=1
i=2
while i**2<=X:
    j=2
    while i**j<=X:
        if x_max<i**j:
            x_max = i**j
        j+=1
    i+=1
print(x_max)

Submission status: Accepted

Solution code:
X = int(input())

num = 0
for i in range(1, X + 1):
    if i**2 < X:
        num = i

ans = 1
for i in range(1, num + 1):
    for j in range(2, num + 1):
        x = i**j
        if x > X:
            break

        if ans < x:
            ans = x

print(ans)

Submission status: Accepted

Solution code:
hoge = [False] * 1080
hoge [1] = True
for i in range(2, 1080):
 x = i*i
 while(x < 1080):
  hoge[x] = True
  x *= i

X = input()

while not hoge[X]: X -= 1
print X

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
n = int(X**0.5)

result = 1
for i in range(2,n+1):
    p = 2
    while X>=pow(i,p):
        p += 1

    tmp = pow(i,p-1)
    if result <= tmp:
        result = tmp

print(result)

Submission status: Accepted

Solution code:
import math


X = int(input())

p = 2
q = 2
tmp = 4

while p < math.sqrt(X):
    q = 2
    while 1:
        if p ** q > X:
            break
        else:
            if tmp < p ** q:
                tmp = p ** q
            q += 1
    p += 1
if X > 3:
    print(tmp)
else:
    print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def calcPow(X):
    num = int(math.sqrt(X))
    Max = 0

    if(X <= 3):
        return X

    for i in range(2,num+1):
        for j in range(2,X):
            if(pow(i,j) > X):
                if(pow(i,j-1) > Max):
                    Max = pow(i,j-1)
                    break
                break

    return Max


if __name__ == '__main__':
    X = int(input())

    print(calcPow(X))

Submission status: Accepted

Solution code:
N=int(input())
result = [1]
for i in range(2,1001):
  for j in range(2,11):
    if pow(i,j) <= N and pow(i,j) not in result:
      result.append(pow(i,j))
print(max(result))

Submission status: Accepted

Solution code:
x = int(input())
a = 1
b = 2
p = 2
while True:
    while True:
        if b**p <= x:
            a = max(a, b**p)
            p += 1
        else:
            p = 2
            break
    b += 1
    if b**p > x:
        break
print(a)

Submission status: Accepted

Solution code:
from itertools import chain, count, takewhile

x = int(input())

if x > 1:
  ps = takewhile(lambda p: 2**p <= x, count(2))
  bps = (takewhile(lambda y:y <= x, (b**p for b in count(1))) for p in ps)
  print(max(chain.from_iterable(bps)))
else:
  print(1)

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:
      ans=max(ans, i**j)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
c = 1
for i in range(2,int(x**0.5) + 1):
    k = 2
    while True:
        if x < i**k:
            c = max(i**(k-1),c)
            break
        else: k += 1 
                
            
print(c)

Submission status: Accepted

Solution code:
X = int(input())

b = 3
ans = 1

for i in range(2,X+1):
        t = i ** 2
        if t <= X:
            while(1):
                t = i ** b
                if t <= X:
                    b = b + 1
                else:
                    b = 3
                    t = t // i
                    ans = max(ans, t)
                    break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(1,101):
    for j in range(2,11):
        k = i**j
        if k <=n:
            l.append(k)
print('{}'.format(max(l)))

Submission status: Accepted

Solution code:
import sys
X = sys.stdin.readline() 
x = int(X)
n = 1
m = 1
ans = 1
for i in range(9):
    n=1
    b = i+2
    a = 1
    while n <= x:
        a+=1
        n = a**b
        if n<=x and n>=ans:
            ans = n
print(ans)

Submission status: Accepted

Solution code:
import math
x = int(input())
cand_list = [1]
for i in range(int(math.sqrt(x)), 1, -1):
    ans = i
    while(ans <= x):
        cand_list.append(ans)
        ans *= i

print(max(cand_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

X = int(input())

power = [1]
for i in range(2, X):
    if pow(i, 2) > X:
        break
    k = i
    j = 2
    while k <= X:
        if pow(i, j) > X:
            break
        power.append(pow(i, j))
        k = pow(i, j)
        j += 1

print(max(power))

Submission status: Accepted

Solution code:
from math import sqrt, log2, floor
MAX_X = 1000
ALL_EXPONENTIAL = [
    b**p
    for b in range(1, floor(sqrt(MAX_X)) + 1)
    for p in range(2, floor(log2(MAX_X)) + 1)]

X = int(input())
assert 1 <= X <= MAX_X
print(max(filter(lambda candidate: candidate <= X, ALL_EXPONENTIAL)))

Submission status: Accepted

Solution code:
X = int(input())
max = [1]
n = int(X**(1/2))
for b in range(2, n+1):
    p = 2
    while b**p < X:
        p += 1
    if b**p == X:
        max.append(b**p)
    else:
        max.append(b**(p-1))
max.sort(reverse = True)
print(max[0])

Submission status: Accepted

Solution code:
X = int(input())

beki = []

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

print(max(beki))

Submission status: Accepted

Solution code:
A=input()
a=int(A)
b=round(a*(1/2))
n2=1
for i in range(2,b):
    for x in range(2,b):
        if n2 <= a:
            n1=(i)**(x)
            if n2 <= n1 and n1 <= a:
                n2 = n1
                #print(n2)
                n1
print(n2)

Submission status: Accepted

Solution code:
import math
def check(X):
	maximum = 0
	for i in range(1, math.floor(math.sqrt(X))+1):
		if i == 1:
			maximum = 1
			continue
		j = 2
		while True:
			tmp = i ** j
			if tmp > X:
				break
			if tmp >= maximum:
				maximum = tmp
			j += 1
	return maximum

print(check(int(input())))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

x = int(input())
b = 2
p = 2

max_num = 1
if x == 1:
  print(1)
  sys.exit()
while b ** p <= x:
  while b ** p <= x:
    if b ** p > max_num:
      max_num = b ** p
    p += 1

  p = 2
  b += 1

print(max_num)

Submission status: Accepted

Solution code:
def abc097_b():
    x = int(input())
    if x == 1:
        return 1

    n = int(x ** 0.5)
    ans = []
    for i in range(2, n + 1):
        tmp = i
        while tmp * i <= x:
            tmp *= i
        ans.append(tmp)

    return max(ans)


print(abc097_b())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    X = int(stdin.readline().rstrip())
    max_ = 1
    for a in range(1, X):
        if a ** 2 > X:
            break
        for b in range(2, X):
            if a ** b <= X:
                max_ = max(max_, a ** b)
            else:
                break
    print(max_)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x = int(arr_data[0][0])

b = 1
p = 2
maxdata = 1

while b ** p < x:

    chkflg = True

    while chkflg:

        if b ** p <= x:

            if maxdata <= b ** p:
                
                maxdata = b ** p

            b += 1

        else:

            b = 2
            p += 1
            chkflg = False

print(maxdata)

Submission status: Accepted

Solution code:
import math

x = int(input())

b = 2
max_v = 1
while b < math.sqrt(x):
    p = 1
    while b**p <= x:
        # print(b, p)
        max_v = max(max_v, b**p)
        p += 1
    b += 1

print(max_v)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

print(max)

Submission status: Accepted

Solution code:
X = int(input())
max1 = 1
max2 = 0

for b in range(1, X+1):
    for q in range(2, X+1):
        
            
        if b**q > X:
            break
        
        max1 = b**q
        
    if max1 > max2:
        max2 = max1
        
print(max2)

Submission status: Accepted

Solution code:
X=int(input())

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

Submission status: Accepted

Solution code:

X = int(input())
#X = 999

max = 1
if X != 1:
    for b in range(2,X):
        y = 0
        p = 2
        while 1:
            pre_y = y
            y = pow(b,p)
            p += 1
            if y > X:
                if pre_y > max:
                    max = pre_y
                break
print(max)

Submission status: Accepted

Solution code:
import math

# input
X = int(input())

ans = 1

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

print (ans)

Submission status: Accepted

Solution code:
X = int(input())
ret = 1
for i in range(2, 32):
    p = 2
    while i ** p <= X:
        ret = max(ret, i ** p)
        p += 1

print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())
a=[]
for i in range(0,32):
  for j in range(2,11):
    if i**j<=X:
      a.append(i**j)
    else:
      pass
print(max(a))

Submission status: Accepted

Solution code:
N = int(input())

max_num = 0

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

print(max_num)

Submission status: Accepted

Solution code:
a=int(input())
if(a<4):print(1)
else:
  ma=1
  for i in range(1,int(a**0.5)+1):
    for j in range(2,1000):
      x=i**j
      if(x>a):break
      ma=max(ma,x)
  print(ma)