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:
n = int(input())
c = 1
for i in range(1, n):
    for j in range(2, n):
        if i**j<=n:
            c=max(c, i**j)
        else:break
print(c)

Submission status: Accepted

Solution code:
X = int(input())
x = int(X ** 0.5)
ans = [1]

for i in range(2,x+1):
    y = i
    while i <= X:
        i = i*y
    ans.append(i//y)
print(max(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import numpy as np
import math
import re

n = int(input())

l = []
for i in range(n):
    for j in range(2,32):
        if i**j <= n:
            l.append(i**j)
        else:
            break;
if n == 1:
    print(1)
else:
    print(max(l))

Submission status: Accepted

Solution code:
X = int(input())

z=[]
for i in range(1,32):
  for j in range(2,15):
    if i**j <= X:
      z.append(i**j)
    else:
      continue

print(max(z) if len(z) != 0 else 0)

Submission status: Accepted

Solution code:
def is_power(n):
    for p in range(2, 10):
        for b in range(1, 32):
            if b**p == n:
                return True
            if b**p > n:
                break

    return False


x = int(input())
for i in range(x, 0, -1):
    if is_power(i):
        print(i)
        break

Submission status: Accepted

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

for i in range(2, 32):
    for j in range(2,10):
        if i**j <= x:
            z = max(z,i**j)
    
print(z)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for b in range(1001):
    for p in range(2, 11):
        if b**p > x:
            break
        ans = max(ans, b**p)
print(ans)

Submission status: Accepted

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

for i in range(2, int(math.sqrt(X))+1) :
    for j in range(2, int(math.log2(X))+1) :
        if (i**j <= X):
            max_num = max(max_num, i**j)
        else:
            break
print(max_num)

Submission status: Accepted

Solution code:
X=int(input())
l=[]
for i in range(1,X+1):
    for j in range(2,11):
        if i**j>X:
            break
        l.append(i**j)
l.sort()
print(l[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

x = int(input())
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
X = int(input())
x = int(X**0.5)
num = []
if X <= 3 :
    print(1)
else :
    for b in range(2,x+1) :
        p = 2
        while b**p <= X :
            p += 1
        num.append(b**(p-1))
    print(max(num))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(X: int):
    v = [1]
    for i in range(2, X + 1):
        sq = i
        while True:
            sq *= i
            if X < sq:
                break
            v.append(sq)
    print(sorted(v)[-1])


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

for i in range(2, 1001):
    for j in range(2,11):

        temp = i**j

        if temp <= x:
            L.append(temp)
        else:
            break

L.sort()

print(L[-1])

Submission status: Accepted

Solution code:
import sys

X = int(input())

X_l = list(range(1,X+1))
box = set()

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

for i in X_l:
    for j in range(2, X+1):
        if i ** j in X_l:
            box.add(i ** j)
        elif i ** j > X:
            break

print(max(box))

Submission status: Accepted

Solution code:
# ABC097B - Exponential
x = int(input())
lst = []

for i in range(1, 32):
    for j in range(2, 10):
        if i ** j == x:
            print(x)
            exit()
        elif i ** j < x and i ** j not in lst:
            lst.append(i ** j)
        elif i ** j > x:
            break
            
lst.append(x)
lst = sorted(lst)

print(lst[lst.index(x) - 1])

Submission status: Accepted

Solution code:
import math

X = int(input())

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

l.sort()

print(l.pop())

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
for b in range(X + 1):
	for p in range(2, 10):  #2^10=1024
		tmp = b ** p
		if tmp <= X and tmp > ans:
			ans = tmp
print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import bisect
n=int(input())
l=[1]
for i in range(2,int(1000**0.5)+1):
    j=2
    while i**j<=1000:
        l.append(i**j)
        j+=1
l=list(set(l))
l.sort()
print(l[bisect.bisect_left(l,n+1)-1])

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
X = int(input())

bekijosu=[1]

for i in range(2, 1001):
    for j in range(2,10):
        if i ** j <= 1000:
            bekijosu.append(i ** j)

print(max([n for n in bekijosu if n <= X]))

Submission status: Accepted

Solution code:
import math
N = int(input())
m = 0
for i in range(int(math.sqrt(N))):
  n = i + 1
  tmp = 1
  for j in range(N):
    tmp *= n
    if tmp > N:
      break
    if tmp > m:
      m = tmp
print(m)

Submission status: Accepted

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

print(max(list))

Submission status: Accepted

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

for b in range(1, x+1):
    for p in range(2, 100):
        num = pow(b, p)
        if num <= x:
            ans.append(num)
        else:
            break

print(max(ans))

Submission status: Accepted

Solution code:
X = int(input())

bekijos = set()
for b in range(1, 1001, 1):
  for p in range(2, 1001, 1):
    a = b**p
    if a > 1000: break
    bekijos.add(a)

xs = set()
for x in range(1, X+1, 1):
  xs.add(x)    
    
print(max(bekijos&xs))

Submission status: Accepted

Solution code:
N = int(input())

if N < 4:
	print(1)
	exit()

vmax = 0
for i in range(2, N):
	v = i ** 2
	if N < v:
		break
	while True:
		v *= i
		if N < v:
			vmax = max(vmax, v // i)
			#print(i, v // i, vmax)
			break

print(vmax)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(X: int):

    cand = [1]
    for i in range(2, 34):
        beki = i*i
        while beki*i <= X:
            beki *= i
        if beki <= X:
            cand.append(beki)
    print(max(cand))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X=int(input())
res=1
for i in range(1,X+1):
    for j in range(2,11):
        for k in range(35):
            if i==k**j:
                res=i
print(res)

Submission status: Accepted

Solution code:
ans = 0

X = int(input())
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:
import math
ans = 0
X = int(input())
if X<4:
    print(1)
else:
    for i in range(2,math.ceil(math.sqrt(X))):
        for j in range(math.ceil(math.log(X)/math.log(i))+1):
            if i**j <= X:
                ans = max(i**j,ans)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

nums = [1]
for i in range(2, 32):
    for j in range(2, 11):
        n = i ** j
        if n > X:
            break
        nums.append(n)

print(max(nums))

Submission status: Accepted

Solution code:
x = int(input())

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

print(answer)

Submission status: Accepted

Solution code:
x=int(input())

exp=set([1])
for i in range(2, 32):
	v = i*i
	while v <= x:
		exp.add(v)
		v *= i
print(max(exp))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = int(input())
p = 0

for i in range(1,32):
    for j in range(2,10):
        k = i ** j
        if k <= s:
            if k > p:
                p = k
print(p)

Submission status: Accepted

Solution code:
X = int(input())

ans = 1
for b in range(1, X + 1):
    for p in range(2, X + 1):
        if b ** p <= X:
            ans = max(ans, b ** p)
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
X = int(input())
b = 1
p = 2
ans = 0
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:
n=int(input())
ans=0
for i in range(40):
  if i**2 <= n and ans<=i**2:
    ans=i**2
  if i**3 <= n and ans<=i**3:
    ans=i**3
  if i**5 <= n and ans<=i**5:
    ans=i**5
  if i**7 <= n and ans<=i**7:
    ans=i**7
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019/04/12
# AtCoder Beginner Contest 097 - B

b = int(input())
max = 0

for i in range(1, 33):
    for j in range(2, 11):
        val = i**j
        if val > b:
            break
        
        if max < val:
            max = val

print(max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
ans = []
for b in range(1, X//2):
    for p in range(2, X//2):
        t = b**p
        if (t <= X):
            ans.append(t)
if (len(ans) == 0):
    print(1)
else:
    print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
lists = []
max = 1
for i in range(1,X+1):
    for j in range(2,X+1):
        if i**j <= X:
            if max < i**j:
                max = i**j
        elif i**j > X:
            break
print(max)

Submission status: Accepted

Solution code:
x = int(input())

def isPrime(n):
  if n%2 == 0 or n%3 == 0: return True
  if n<3: return False
  for i in range( 2, int(n**0.5) +1):
    if n%i == 0: return False
  return True

primes = [i for i in range(1, 32) if isPrime(i)]

def isExp(n):
  if n==1: return True
  for i in [p for p in primes if p<int(n**0.5)+1]:
    p = 0
    while i**p<=n:
      if i**p == n: return True
      p+=1
  return False

def solve():
  for i in range(x,0,-1):
    if isExp(i): return i

print(solve())

Submission status: Accepted

Solution code:
import math
X = int(input())
answer = 0
for i in range(1,math.ceil(X**0.5)+1):
  for j in range(2,11):
    if i**j <= X:
      answer = max(i**j,answer)

print(answer)

Submission status: Accepted

Solution code:
X = int(input())

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
import math
x = int(input())
t = math.floor(x ** (1/2))
a = [1]
for i in range(2, t+1):
    b = i
    while (b <= x):
        a.append(b)
        b *= i
print(max(a))

Submission status: Accepted

Solution code:
#coding: utf-8
X = int(input())
ans = 0
for b in range(1, 32):
    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())
r = int(X ** 0.5)
ans = 0
for i in range(1, r + 1):
    a = 0
    for j in range(1, 11):
        if i ** j <= X:
            a = i ** j
        else:
            break
    ans = max(ans, a)
print(ans)

Submission status: Accepted

Solution code:
import bisect
a = []
for pw in range(2,1001):
    for x in range(1,1001):
        nw = x**pw
        if nw > 1000:
            break
        a.append(nw)
a = sorted(a)
x = int(input())
y = bisect.bisect_right(a,x)
print(a[y-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(raw_input())
ans = 1
for b in range(1,35):
	for p in range(2,10):
		tmp = b ** p
		if tmp <= x:
			ans = max(ans, tmp)
print ans

Submission status: Accepted

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

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())
res_list = [1]
for b in range(1,x+1):
    for p in range(2,x+1):
        if b**p <= x:
            res_list.append(b**p)
        else:
            break
print(max(res_list))

Submission status: Accepted

Solution code:
X = int(input())

def my_pow(b,p):
    tmp = 1
    for i in range(0,p):
        tmp *= b
    return tmp

res = []
for b in range(2,100):
    for p in range(2,10):
        beki = my_pow(b,p)
        if beki > X:
            break;
        res.append(beki)

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

print(max(res))

Submission status: Accepted

Solution code:
X = int(input())

ans = 0
for b in range(X+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

n = int(input())
limit = int(math.sqrt(n))
ansi = 0
exp = [1]
i = 2
beki = 1
while i <= limit:
    temp = i**beki
    if temp <= n:
        exp.append(temp)
        beki += 1
    else:
        beki = 1
        i += 1

exp.sort()
print(str(exp[-1]))

Submission status: Accepted

Solution code:
import math
x = int(input())
ans = 1
for b in range(2,int(math.sqrt(x)) + 1):
	m = b
	while(m * b <= x):
		m*=b
	ans = max(ans,m)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

def check(num):
    for i in range(2, 33):
        j = i * i
        while j < num:
            j *= i
        else:
            if j == num:
                return True
    return False

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

while True:
    if check(n):
        print(n)
        exit()
    n -= 1
    if n == 1:
        break

print(1)

Submission status: Accepted

Solution code:
from sys import stdin
X=int(stdin.readline().rstrip())
dif=1000
for i in range(1,32):
    for j in range(2,10):
        if pow(i,j) > X:
          break
        if X-pow(i,j) < dif:
            dif=X-pow(i,j)
            ans=pow(i,j)
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
t=[1]
for n in range(2, int(x**0.5)+1):
    for p in range(2, 11):
        v = n**p
        if v > x:
            break
        t.append(v)
print(max(t))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
X = int(input())
max_num = []
temp_max = 0
for i in range(1,int(math.sqrt(X))+1):
    for j in range(1,10):
        if i**j <= X:
            if i**j > temp_max:
                temp_max = i**j
print(temp_max)

Submission status: Accepted

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

x = int(input())

ans = 0

for i in range(1,1001):
    for j in range(2,1001):
        if x >= i ** j:
            ans = max(ans,i ** j)
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
def judge(x):
    for i in range(2, x):
        t = x
        while t != 1:
            if t % i == 0:
                t //= i
            else:
                break
            if t == 1:
                return True
    return False


x = int(input())

ans = 1

for i in range(x, 1, -1):
    if judge(i):
        ans = i
        break

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
ans=1
for i in range(40):
  for j in range(2,11):
    if i**(j+1)>a and i**j<=a:
      ans=max(ans,i**j)
      break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

beki = []
for i in range(1,40):
  for j in range(2,10):
    if i**j <= 1000 and i**j not in beki:
      beki.append(i**j)
beki.sort()

index = bisect.bisect(beki, x)
print(beki[index-1])

Submission status: Accepted

Solution code:
x = int(input())
j = 2
a = 0
t = 0
if x == 1:
    print("1")
    exit()
for i in range(2,32):
    j = 2
    while True:
        t = i ** j
        if t <= x:
#            print(t)
            j += 1
            a = max(a,t)
        else:
            break
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

from math import sqrt
for i in range(1, X + 1):
    if i == 1:
        ans = i
    for b in range(2, int(sqrt(i)) + 1):
        tmp = b * b
        while tmp < i:
            tmp *= b
        if tmp == i:
            ans = i

print(ans)

Submission status: Accepted

Solution code:
#97
import math
x = int(input())
temp = 1
n = math.ceil(math.sqrt(x))
for i in range(2, n):
    j = 2
    while i**j<=x:
        temp = max(temp, i**j)
        j += 1
print(temp)

Submission status: Accepted

Solution code:
from sys import stdin
X = int(stdin.readline().rstrip())
exps=[1]
for i in range(1,X+1):
    for j in range(2,X+1):
        if 1 <= i**j <= X:
            exps.append(i**j)
        else:
            break
print(max(exps))

Submission status: Accepted

Solution code:
x = int(input())
a = 34
b = 10

# 冪乗数一覧
list_val = []
for i in range(1,a):
    for j in range(2,b):
        if i ** j <= 1000:
            list_val.append(i ** j)
        else:
            break

list_val = list(set(list_val))
list_val.sort()

# 一番近い数字をprint
import bisect

insert_index = bisect.bisect_left(list_val,x)

if list_val[insert_index] == x:
    print(x)
else:
    print(list_val[insert_index-1])

Submission status: Accepted

Solution code:
num=[1]
for i in range(2,32):
  stack=i*i
  while stack<=1000:
    num.append(stack)
    stack*=i
num.sort()
num.reverse()
n=int(input())
for i in num:
  if i<=n:
    print(i)
    exit()

Submission status: Accepted

Solution code:
from math import sqrt
X = int(input())
ans = 1
for i in range(2,int(sqrt(X))+1):
    p = 1
    while True:
        p += 1
        tmp = i**p
        if tmp > X: break
        else:
            if tmp > ans: ans = tmp
print(ans)

Submission status: Accepted

Solution code:
X=int(input())
n=[1]
p=2
while True:
  l = [(i+1)**p for i in range(31) if (i+1)**p<=X]
  if l==[1]:
    break
  else:
    n+=l
    p+=1
print(max(n))

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:
X=int(input())
Y=1
for b in range(1,X):
    for p in range(2,X):
        if b**p<=X:
            Y=max(Y,b**p)
        else:
            break
print(Y)

Submission status: Accepted

Solution code:
X=int(input())
l2=[1,4,8,16,32,64,128,256,512]
l3=[9,27,81,243,729]
l5=[25,125,625]
l6=[36,216]
l7=[49,343]
l10=[100,1000]
le=[n*n for n in range(11,32)]
l=l2+l3+l5+l6+l7+l10+le
m=max([i for i in l if i<=X])
print(m)

Submission status: Accepted

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


def solve(string):
    x = int(string)
    ans = [1]
    for i in range(2, floor(sqrt(x)) + 1):
        ans.append(i**floor(log(x, i)))
        if i**ceil(log(x, i)) <= x:
            ans.append(i**ceil(log(x, i)))
    return str(max(ans))


if __name__ == '__main__':
    print(solve(input()))

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())
select = [1]

for i in range(2, int(X**0.5)+1):
    for j in range(2, 10):
        tmp = i ** j
        if tmp > X:
            break
        select.append(tmp)

select = sorted(set(select))
print(max(select))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

rx = int(pow(X, 0.5)) + 1

result = 1
for i in range(2, rx):
    j = 2
    while True:
        r = i ** j
        if r > X:
            break
        elif result < r:
            result = r
        j += 1
print(result)

Submission status: Accepted

Solution code:
x  = int(input())

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

        if expo <= x:
            ans = max(ans, expo) 

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for i in range(1, 32):
    for j in range(2, 9):
        tmp = i ** j
        if tmp <= x and ans < tmp:
            ans = tmp

print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
ans = []
for i in range(int(math.sqrt(N)) + 1):
    for j in range(int(math.sqrt(N)) + 1):
        if i ** j <= N:
            ans.append(i ** j)
        else:
            break
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#97B
x = int(input())
lst = []
answer = 0

for i in range(40):
	for j in range(2,40):
		if i**j <= x:
			lst.append(i**j)
print(max(lst))

Submission status: Accepted

Solution code:
def exponential(x):
    if x < 4:
        return x
    for i in range(x, 0, -1):
        for p in range(2, int(i**0.5)+1):
            o = i
            while o%p==0:
                o //= p
            if o == 1:
                return i
x = int(input())
print(exponential(x))

Submission status: Accepted

Solution code:
X = int(input())

expos = {1}
for i in range(2, 40):
    e = i ** 2
    while e <= 1000:
        expos.add(e)
        e *= i
print(max(filter(lambda x: x <= X, sorted(expos))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
list=[]
max=0
for i in range(33):
    for j in range(2,11):
        if (i**j)<=1000:    
            list.append(i**j)
for i in range(len(list)):
    if max<list[i] and list[i]<=x:
        max=list[i]
print(max)

Submission status: Accepted

Solution code:
x = int(input())

max_num = 1
for i in range(2, int(x**(1/2)+1) ):
    for j in range(1, 11):
        num = i**j
        if num <= x:
            if num > max_num:
                max_num = num
        else:
            break

print(max_num)

Submission status: Accepted

Solution code:
x = int(input())

num = 0
if x == 1:
    num = 1
else:
    for b in range(2, 33):
        for p in range(2, 11):
            tmp = pow(b, p)
            if tmp <= x and num < tmp:
                num = tmp

print(num)

Submission status: Accepted

Solution code:
x = int(input())

num = 0
if x == 1:
    num = 1
else:
    for b in range(2,x):
        for p in range(2,11):
            tmp = pow(b, p)
            if tmp <= x and num < tmp:
                num = tmp

print(num)

Submission status: Accepted

Solution code:
x = int(input())

l = []

for i in range(1,33):
	for j in range(2,11):
		n = i**j
		if n <= x:
			l.append(n)
		if n > 1000:
			break
            
print(max(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
m = int(pow(n,1/2)) + 1
k = 0
for i in range(n+1):
  if n < pow(i,2):
    break
  if k <= pow(i,2):
    k = pow(i,2)  
  for z in range(3,n):
    if n < pow(i,z):
      break
    elif k <= pow(i,z):
      k = pow(i,z)
 
print(k)

Submission status: Accepted

Solution code:
x=int(input())
li=[]
for b in range(1,40):
    for p in range(2,11):
        li+=[b**p]
li=sorted(li)
ans=0
f=0
for i in range(len(li)):
    if li[i]>x and f==0:
        ans=li[i-1]
        f=1
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
X = int(input())

result = 1
for b in range(1, 32):
    for p in range(2, X+1):
        if X >= b**p:
            result = max(result, b ** p)
print(result)

Submission status: Accepted

Solution code:
from math import sqrt


def exponential(X: int) -> int:
    sq = int(sqrt(X) + 1)
    max_exp = 1
    for base in range(2, sq):
        num = 1
        while num * base <= X:
            num *= base
        max_exp = max(max_exp, num)
    return max_exp


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

Submission status: Accepted

Solution code:
def solve(X):
    ans = 1
    p = 2
    while True:
        b = int((X ** (1/p)))
        if (b+1) ** p <= X:
            ans = max(ans, (b+1) ** p)
        elif b == 1:
            break
        elif b ** p <= X:
            ans = max(ans, b ** p)
        p += 1
    return ans

X = int(input())
print(solve(X))
#for X in range(1,1011):
#    print(X, solve(X))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(X):
  b = i+1
  for i in range(8):
   k = i + 2
   if(pow(b,k) <= X):
    if(ans < pow(b,k)):
     ans = pow(b,k)
 
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

ans = 1
for i in range(1,X+1):
  for j in [2, 3, 5, 7]:
    if(i**j <= X):
      ans = max(ans, i**j)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

l = []

for n in range(2,X):
    for p in range(2,10):
        y = n**p
        if y>X:
            break
        else:
            l.append(y)

if l ==[]:
    l.append(1)

print(max(l))