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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = 1
count = 0
j=2
x=int(input())
for i in range(2,x):
    while i**j<=x:
        ans=max(ans,i**j)
        j+=1
    j=2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

k = 1000
maxk = 1

for j in range(n,1,-1):#5,4,3,2で回す時
	for i in range(j-1,1,-1):
		#print(j,i)
		if j%i ==0 :
			k = j
			t = i
			while k>=t :
				#print('-------')
				#print(k,t)
				k = k/t
				#print(k)
				if k == 1 and maxk < j:				
					maxk = j
					#print('Yes')
					break
				
print(maxk)

Submission status: Accepted

Solution code:
def ans(n):
    pow_2 = int(n**(0.5))
    pow_exeption = [32,128,243]
    #print(pow_2)
    ans = pow_2**2
    for i in pow_exeption:
        if i <= n:
            ans = max(i,ans)
    for i in range(1,11):
        if i**3 <= n:
            ans = max((i**3),ans)
        
    return(ans)
n = int(input())
for i in range(n,n+1):
    print(ans(i))

Submission status: Accepted

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

def main():
    X = int(input())
    max_num = 1
    for b in range(1,X+1):
        for p in range(2,X+1):
            current = b ** p
            if current <= X:
                max_num = max(max_num,current)
            else:
                break
    print(max_num)        
            
            

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for i in range(10000):
    for p in range(2,10000):
        if i**p > x:
            break
        else:
            if i**p > ans:
                ans = i**p

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
import math
if x < 4 :
    print(1)
elif 4 <= x :
    exponetiallist = []
    pmax = math.floor(math.log2(x))
    for b in range(2, x + 1) :
        for p in range(2, pmax +1) :
            if b ** p <= x :
                exponetiallist += [b ** p]
    print(max(exponetiallist))

Submission status: Accepted

Solution code:
import math
x = int(input())
limit = math.ceil(math.sqrt(x))
min_diff = x - 1
for b in range(2, limit):
  temp_b = b
  while temp_b <= x:
    temp_b *= b
  bp = int(temp_b / b)
  if bp == x:
    print(x)
    exit()
  elif x - bp < min_diff:
    min_diff = x - bp
print(x - min_diff)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    ans = 0
    for i in range(1, 1000):
        n = i
        for _ in range(2, 1000):
            n *= i
            if n > X:
                break
            ans = max(ans, n)
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
a = 2
while a*a<=X:
    r = a*a
    while r<=X:
        ans = max(ans, r)
        r*=a
    a+=1

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

n = int(stdin.readline().rstrip())

li = [1]

for i in range(2,34):
    for s in range(2,10):
        if i**s <= 1000:
            li.append(i**s)
        else:
            break
    
li = list(set(li))

li.sort()

print(li[bisect.bisect(li,n)-1])

Submission status: Accepted

Solution code:
X=int(input())
l=[]
for i in range(1,32):
  for j in range(2,10):
    l +=[i**j]
    if i**j>1000:
      break
se=set(l)
for k in range(X):
  if X-k in se:
    print(X-k)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

ans = 0
for i in range(1, 35):
    for j in range(2, 10):
        if ans < i**j and i**j <= X:
            ans = i**j

print(ans)

Submission status: Accepted

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

b = 2
perfect_power = 0

if x < 4:
    perfect_power = 1
else:
    while b < x:
        p = 2
        while b ** p <= x:
            perfect_power = max(perfect_power, b ** p)
            p += 1
        b += 1

print(perfect_power)

Submission status: Accepted

Solution code:
X = int(input())
ans = set()
for i in range(1,int(X)):
	for j in range(2,11):
		if i**j <= X:
			ans.add(i**j)

ans_list = list(ans)
if len(ans_list)==0:
	print(1)
else:
	print(max(ans_list))

Submission status: Accepted

Solution code:
N = int(input())
import math
n = math.floor(N**0.5)

A = [1]
for i in range(2,n+1):
    j = 2
    while i**j <= N :
        A.append(i**j)
        j += 1
ans = max(A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
X=int(input())


ans=1
for i in range(2,X+1):
    temp=i*i
    while temp<=X:
        temp*=i
    if temp!=i*i:
        ans=max(ans,temp//i)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
x=int(input())
ans=[]
if x==1:
    print(1)
else:
    for i in range(1,x+1):
        for j in range(2,x+1):
            if i**j<=x:
                ans.append(i**j)
            else:
                break
    ans.sort(reverse=True)
    print(ans[0])
#print(ans)

Submission status: Accepted

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

for i in range(2, X):
    for j in range(2, X):
        e = i ** j
        if e <= X:
            if e > ans:
                ans = e
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
X = int(input())
flag = [0 for i in range(X+1)]
flag[1] = 1

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

Submission status: Accepted

Solution code:
x = int(input())
m = 1
for i in range(2, x):
    p = 2
    while pow(i, p) <= x:
        if m <= pow(i, p):
            m = pow(i, p)
        p += 1
print(m)

Submission status: Accepted

Solution code:
X = int(input())
nums = []
for b in range(1, 100):
    for p in range(2, 100):
        num = b**p
        if num <= X:
            nums.append(num)
print(max(nums))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def main():
    x=int(input())
    a=1
    for i in range(2,x+1):
        j=2
        while True:
            k=i**j
            if k>x:
                break
            if k>a:
                a=k
            j+=1
    print(a)

main()

Submission status: Accepted

Solution code:
def factorization(n):
    s = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            s.add(cnt)

    if temp!=1:
        s.add(1)

    if s==set():
        s.add(1)

    return s
  
n = int(input())
if n < 4:
  print(1)
else:
  for i in range(n, 0, -1):
    s = factorization(i)
    if len(s)==1 and s.pop()>=2:
        print(i)
        break

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for i in range(1, x+1):
    for j in range(x.bit_length()):
        nxt = i**(j+2)
        if nxt <= x and ans < nxt:
            ans = nxt
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

x = inp()
for i in range(x,0,-1):
    for b in range(1,33):
        for p in range(2,11):
            if i == b**p:
                print(i)
                quit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())
c=[]
for i in range(0,X):
  for k in range(2,10):
    if (i+1)**k<=X:
      c.append((i+1)**k)
print(max(c))

Submission status: Accepted

Solution code:
N = int(input())
se = set(x**e for x in range(33) for e in range(2,11) if x**e<=N)
print(max(se))

Submission status: Accepted

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


def main():
    X = int(input())
    
    ans = 1
    for a in range(2, math.ceil(math.sqrt(X))):
        b = 2
        while a**(b+1) <= X:
            b += 1
        ans = max(ans, a**b)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

n = 1
for b in range(1,X):
    for p in range(2,X):
        if b**p <= X:
            if n < b**p:
                n = b**p
        else:
            break
    if b**2 > X:
        break

print(n)

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 math
X = int(input())
N = int(math.sqrt(X))+1
ans = 1
for n in range(2,N):
    b = n
    while b*n <= X:
        b = b*n
    if ans < b:
        ans = b
print(ans)

Submission status: Accepted

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

n = int(x**0.5)
for i in range(n, 1, -1):
    j = 2
    while True:
        m = i**j
        if m > x:
            break
        if ans < m:
            ans = m
        j += 1

print(ans)

Submission status: Accepted

Solution code:
X=int(input())
if X==1:
  print(1)
else:
  ans=0
  import math
  for i in range(2,int(math.sqrt(X))+1):
    val=i*i
    while val*i<=X:
      val=val*i
    ans=max(ans,val)
    if ans==X:
      break
  print(ans)

Submission status: Accepted

Solution code:
from math import floor
X = int(input())
if X != 1000:
    tmp = []
    for i in range(2,100):
        tmp.append(floor(X**(1/i))**i)
    print(max(tmp))
else:
    print(1000)

Submission status: Accepted

Solution code:
import math
n = int(input())
j = 2
tmp = 0
Max = 1
for i in range(2,n):
  while(n > tmp):
    tmp = i**j
    j+=1
    if(Max < tmp and n >= tmp):
      Max = tmp
  j = 2
  tmp = 0
print(Max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = [1]
for b in range(2, int(math.sqrt(X))+1):
  p = 2
  while True:
    if b**p <= X:
      ans.append(b**p)
      p+=1
    else:
      break
print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
candidates = set([1])

for b in range(2, int(1000**1/2)+1):
  p = 2
  while b**p <= 1000:
    candidates.add(b**p)
    p += 1

X = int(input())

for c in sorted(candidates, reverse=True):
  if c <= X:
    print(c)
    exit()

Submission status: Accepted

Solution code:
x = int(input())
l = []
for i in range(1, x+1): #b
  for j in range(2, 11): #p
    bq = i**j
    if bq > x:
      break
    l.append(bq)
print(max(l))

Submission status: Accepted

Solution code:
x = int(input())
max_num = 0
for elm1 in range(1,int(x ** 0.5) + 1):
    for elm2 in range(1,int(x ** 0.5) + 1):
        tmp_num = elm1 ** elm2
        if tmp_num <= x and tmp_num >= max_num:
            max_num = tmp_num
        else:
            continue
print(max_num)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

ans = 1
for b in range(1, X+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())
ans = [1]
for i in range(2, x):
    for j in range(2,11):
        ad = i**j
        if ad > x:
            break
        ans.append(ad)
print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())

for i in range(x, 0, -1):
    for j in range(2, i):
        s = i
        while s%j == 0:
            t = s % j
            s = s // j
            if s == 1 and t == 0:
                print(i)
                exit()       
print(1)

Submission status: Accepted

Solution code:
x=int(input())
a=[]
for i in range(40):
    for j in range(2,10):
        if i**j <= x:
            a.append(i**j)
b=list(set(a))
b.sort()


print(max(b))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
x = int(input())
upper = int(np.sqrt(x))
ans = 1

for i in range(2,upper+1):
    ct = 0
    while i**ct <= x:
        ct += 1       
    ans = max(ans,i**(ct-1))
    
print(ans)

Submission status: Accepted

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

for b in range(1,x):
  for p in range(2,x):
    if b**p<=x:c=max(c,b**p)
    else:break

print(c)

Submission status: Accepted

Solution code:
n = int(input())

x = []
for i in range(1,33):
    x = x + [i**j for j in range(2,10)]
x.sort()

import bisect

b = bisect.bisect_right(x,n)
print(x[b-1])

Submission status: Accepted

Solution code:
x = int(input())

z = []
for p in range(2,10):
    for b in range(1,32):
        if b**p <= x:
            z.append(b**p)
print(max(z))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect as bi

X=int(input())

l=[]

for p in range(2,11):
    l.extend([x**p for x in range(1,int(1000**(1/p))+2)])

l.sort()

ind=bi.bisect_right(l,X)-1
print(l[ind])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    x = int(input())
    if x < 4:
        return 1
    elif x < 8:
        return 4
    elif x < 9:
        return 8
    l = [i**j for i in range(1,x+1) for j in range(2,int(x**0.5)) if i**j<=x]
    return max(l)
        
if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
N = int(input())
l = {1}
for i in range(2,32):
  j = 2
  while(i ** j <= N):
    l.add(i ** j)
    j += 1

for i in range(N, 0, -1):
  if(i in l):
    print(i)
    break

Submission status: Accepted

Solution code:
N=int(input())
ans=1
S=[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]
    
i=0
while S[i] <= N:
    i+=1
    if len(S)<=i:
        break
    
print(S[i-1])

Submission status: Accepted

Solution code:
X=int(input())
ans=1
for i in range(X):
    for j in range(2,X):
        tmp=i**j
        if tmp>X:
            break
        else:
            if tmp>ans: ans=tmp
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
m = 1
for i in range(1, 40):
    for j in range(2, 15):
        beki = i ** j
        if beki > X:
            continue
        if m < beki:
            m = beki
print(m)

Submission status: Accepted

Solution code:
x = int(input())
c = 1
for i in range(2,11):
  for n in range(1,32):
    ni = n**i
    if ni > c and x >= ni:
      c = ni
print(c)

Submission status: Accepted

Solution code:
x = int(input())

if x == 1000 :
    print(1000)
else :
    beki = []
    for i in range(2, 10) :
        beki.append(int(x ** (1 / i)) ** i)

    print(max(beki))

Submission status: Accepted

Solution code:
import math
X = int(input())
n = math.ceil(X**0.5+1)
lst = []
if X == 1 or X == 2 or X == 3:
  print(1)
  exit()
for i in range(2, n):
  a = 2
  while i**a <= X:
    lst.append(i**a)
    a += 1
lst.sort()
print(lst[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for i in range(1, x+1):
    for j in range(1, int(x**0.5)+1):
        for k in range(2, 10):
            if j**k == i and ans < i:
                ans = i
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
a = [1]
for i in [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31]:
    j = 2
    while i**j <= 1000:
        a.append(i**j)
        j += 1
a = sorted(a)
for k in a:
    if k<=x:
        ans = k
    else:
        break
        
print(ans)

Submission status: Accepted

Solution code:
import math
X=int(input())
u=int(math.sqrt(X))+1
ans=1
for i in range(2,u):
  tmp=1
  while i**tmp<=X:
    tmp+=1
  ans=max(ans,i**(tmp-1))
  
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = []
if x < 4:
  print(1)
else:
  for i in range(2, x):
    temp = i
    if i**2 == x:
      print(x)
      break
    elif i**2 > x:
      print(max(ans))
      break
    else:
      while True:
        temp *= i
        if temp > x:
          temp //= i
          break
      ans.append(temp)

Submission status: Accepted

Solution code:
import bisect

X = int(input())

ex = [1]
for i in range(2,33):
    x = i*i
    while x <= 1000:
        ex.append(x)
        x = x*i

ex = list(set(ex))
ex.sort()
        
print(ex[bisect.bisect_right(ex, X)-1])

Submission status: Accepted

Solution code:
x=int(input())
l=[1]
for i in range(2,32):
    for k in range(2,10):
        if i**k<=1000:
            l.append(i**k)
        else:
            break
l=list(set(l))
l.sort()
#print(l)
for i in range(1,len(l)):
    if x<l[i]:
        print(l[i-1])
        break
else:print(1000)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    x = int(input().rstrip('\n'))
    mt = 0
    for i in range(1, 1001):
        for j in range(2, 1001):
            if i ** j > x:
                break
            else:
                mt = max(mt, i ** j)
    print(mt)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
import sys

X = int(input())
if X == 1:
    print(1)
    sys.exit()

ans = 0
for b in range(2,34):
    p = 2
    while b**p <= X:
        ans = max(ans,b**p)
        p += 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
b=[]
for i in range(30):
    i+=2
    s=i*i
    while s <=1000:
        b.append(s)
        s=s*i
ans=1
for i in range(len(b)):
    if b[i] <= n and ans < b[i] :
        ans=b[i]
print(ans)

Submission status: Accepted

Solution code:
import math
x=int(input())
n=int(math.sqrt(x))
ans=0
for i in range(1,n+1):
    for j in range(2,10):
        if i**j>x:
            continue
        elif ans<i**j:
            ans=i**j
        else:
            pass
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())
ans=0
for i in range(2,10):
  tmp=int(pow(X,1/i)+1)**i
  if tmp > X:
    tmp=int(pow(X,1/i))**i
  ans=max(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
output = 1
if x == 1:
    print(1)

else:
    for i in range(2, 33):
        for k in range(2, 10):
            if output < i ** k <= x:
                output = i ** k

    print(output)

Submission status: Accepted

Solution code:
#2019/10/03
X = int(open(0).read())
#print(X)
max_exp=1
exp=0
for i in range(1,X+1):
#     print("i", i)
    for j in range(2,X+1):
#         print("j", j)
        exp = i**j
        if exp > X:
            break
        if max_exp < exp:
            max_exp = exp
print(max_exp)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

max_v = 1

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

Submission status: Accepted

Solution code:
x = int(input())
beki = sorted({b**p for b in range(1,100) for p in range(2,100)})
print(max(i for i in beki if i <= x))

Submission status: Accepted

Solution code:
N=int(input())
l=[1]
import math
for n in range(2,N+1):
    for p in range(2,N+1):
        if n**p<=N:
            l.append(n**p)
        else:
            break
print(max(l))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
x=int(input())

ans=0

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

min=x-1
for i in range(2,x+1):
        a=i*i
        while a <= x:
            b=x-a
            if b <= min and b >= 0:
                min=b
                ans=a
                
            a *=i
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
a = 0
for i in range(1,X+1):
    for l in range(2,11):
        if i**l <= X and i**l > a:
            a = i**l
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l =[]
m= range(1,32)
n =range(2,32)
x = int(input())
for i in m:
  for j in n:
    if i**j <=x:
      l.append(i**j)
print(max(l))

Submission status: Accepted

Solution code:
X = int(input())

L = [1]
b = 2
while b <= X**0.5:
    p = 2
    while b**p <= X:
        L.append(b**p)
        p += 1
    b += 1
    
print(max(L))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
if N ==1:
  print(1)
  exit()
else:
  for i in range(int(N**0.5)+1):
    for j in range(100):
      if i**j<=N:
        ans =max(ans,i**j)
      else:
        break
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
li,p,ans = [],1,0

for b in range(2,int(x**0.5//1)+1):
    while b**p<=x:
        ans = max(ans,b**p)
        p += 1
        li.append(b**(p-1))
        if b**p>x:
            p = 1
            break
if x <= 3:
    print(x)
else:
    print(max(li))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

    if x <= 3:
        print(1)
        sys.exit()

    # 事前にべき乗数DBを作っておく・・
    s = set()
    for i in range(2,31+1): # sqrt(1000) = 31.6...
        r = i*i
        while r <= 1000:
            s.add(r)
            r *= i
    t = list(s)
    t.sort()
    t.reverse()

    for i in t:
        if i <= x:
            print(i)
            sys.exit()

bb097()

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
x = int(input())

s = set()
for i in range(1, 32):
    for j in range(2, 10):
        if i**j <= 1000:
            s.add(int(i**j))

l = [int(i) for i in s]
l = sorted(l)

ans = 0
for i in l:
    if i <= x:
        ans = i
    else:
        break

print(ans)

Submission status: Accepted

Solution code:
X = int(input())

num_list = []
for x in range(1, X + 1):
    for i in range(2, 11):
        if (x ** i) <= X:
            num_list.append(x ** i)
        else:
            break


print(max(num_list))

Submission status: Accepted

Solution code:
from sys import exit
n = int(input())
powlist = set()
k = 2
chance = True
if n == 1:
    print(1)
    exit()
while chance:
    for i in range(1, n):
        key = i**k
        if key <= n:
            powlist.add(key)
        else:
            k += 1
            judge = i
            break
    if judge == 2:
        chance = False
print(max(powlist))

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:
r=range(1,32)
l=range(2,32)
x=int(input())
arr=[]
for i in r:
    for j in l:
        if i**j<=x:
            arr.append(i**j)
print(max(arr))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
def gauss_2(n):
    g=0
    while g<=n**(1/2):
        g+=1
    return g-1

def gauss_3(n):
    g=0
    while g<=n**(1/3):
        g+=1
    return g-1
def gauss_4(n):
    g=0
    while g<=n**(1/4):
        g+=1
    return g-1
def gauss_5(n):
    g=0
    while g<=n**(1/5):
        g+=1
    return g-1
def gauss_6(n):
    g=0
    while g<=n**(1/6):
        g+=1
    return g-1
def gauss_7(n):
    g=0
    while g<=n**(1/7):
        g+=1
    return g-1

if n<=3:
    print(1)
elif n not in (125,216,343,512,729,1000):
    print(max(gauss_2(n)**2,gauss_3(n)**3,gauss_4(n)**4,gauss_5(n)**5,gauss_6(n)**6,gauss_7(n)**7))
else:
    print(n)