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

x=int(input())

if x<4:
	print(x)
else:
	result=2
	for i in range(2,x):
		for j in range(2,x):
			if i**j<=x:
				result=max(result,i**j)
			else:
				break
	print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

x = int(input())
 
max_bp = 0
for b in range(1, x + 1):
  for p in range(2, x + 2):
    bp = b ** p
    if bp > x:
      break
    max_bp = max(max_bp, bp)

print(max_bp)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
	x=int(input())
	ans=0
	if x==1:
		ans=1
	else:
		for b in range(1,x-1):
			p=2
			while True:
				if b**p>x or p>x:
					break
				else:
					t=b**p
				p+=1
			ans=max(ans,t)
	print(ans)
resolve()

Submission status: Accepted

Solution code:
def abc():
    e = {1}
    for b in range(2, 1001):
        for p in range(2, 11):
            bp = b ** p
            if bp > 1000:
                continue
            e.add(bp)
    x = int(input().rstrip())
    for n in reversed(range(x+1)):
        if n in e:
            print(n)
            return


abc()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
ans = []
for i in range(X):
    x = X-i
    for s in range(33):
        for j in range(2,11):
            if s ** j == x:
                ans.append(x)
                break
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

x = int(input())
xx = list(reversed(range(1,x+1)))
xxx = set()

for i in range(1, 32):
    for j in range(2, 11):
        if i**j <= 1000:
            xxx.add(i**j)

for i in xx:
    if i in xxx:
        print(i)
        break

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# N = int(sys.stdin.readline())
# S = sys.stdin.readline().rstrip()
#
# ans = 0
# for i in range(N):
#     a = set(Counter(S[:i]).keys())
#     b = set(Counter(S[i:]).keys())
#     ans = max(ans, len(a&b))
# print(ans)

X = int(sys.stdin.readline())

beki = {1}
for i in range(2, 1001):
    e = 2
    while i ** e <= X:
        beki.add(i ** e)
        e += 1
print(max(beki))

Submission status: Accepted

Solution code:
import math

x=int(input())
y=math.floor(math.sqrt(x))
ans=1
temp=1

for i in range(2,y+1):
  while temp*i<=x:
    temp = temp * i
    ans=max(temp,ans)
  else:
    temp=1
print(ans)

Submission status: Accepted

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

se = set()
for i in range(2,math.floor(math.sqrt(x))+1):
  cnt = 2
  while i**cnt <= x:
    se.add(i**cnt)
    cnt += 1
se.add(1)
print(max(se&set(range(1,x+1))))

Submission status: Accepted

Solution code:
x = int(input())

se = set()
for i in range(2,32):
  cnt = 2
  while i**cnt <= 1000:
    se.add(i**cnt)
    cnt += 1
se.add(1)
print(max(se&set(range(1,x+1))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

X = int(input())
b = [1]

for i in range(2, 32):
    p = 2
    while i ** p <= X:
        b.append(i ** p)
        p += 1

print(max(b))

Submission status: Accepted

Solution code:
exp_list = []
for i in range(2,32):
	j = i
	while True:
		j = j * i
		if j > 1000:
			break
		exp_list.append(j)
exp_list = sorted(set(exp_list+[1]))

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

Submission status: Accepted

Solution code:
import math

X = int(input())
ans = 1
cnt = 0
for i in range(2, int(math.sqrt(X)) + 1):
    cnt = 2
    while i ** cnt <= X:
        ans = max(ans, i ** cnt)
        cnt += 1
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
ans=1
for i in range(2,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:
n=int(input())
ans=[]
for x in range(1,32):
    for y in range(2,11):
        if x**y<=n:
            ans.append(x**y)
            
print(max(ans))

Submission status: Accepted

Solution code:

import fractions


def factorize(n):
    l = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            l.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        l.append((n, 1))
    return l


# input
a = int(input())
# calc
for i in range(a, 1, -1):
    out = factorize(i)
    t = []
    for j in out:
        t.append(j[1])
    fn = t[0]
    for k in range(1, len(t)):
        fn = fractions.gcd(fn, t[k])
    if fn > 1:
        print(i)
        exit()
print(1)

Submission status: Accepted

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

x = int(input())
ans_box = [0]*8
for i in range(2, 9):
    for j in range(1, 33):
        if j**i > x:
            ans_box[i-2] = (j-1)**i
            break
print(max(ans_box))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
X = int(input())
ans = 1
for i in range(2, 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:
import math
a = int(input())

res = 1
for i in range(2, a):
    for j in range(2, a):
        if i ** j <= a:
            res = max(res, i**j)
        else:
            break
print(res)

Submission status: Accepted

Solution code:
x = int(input())

c = 0
for i in range(x+1):
    for j in range(2,10):
        d = i ** j
        if d<=x and c<=d:
            c = d
print(c)

Submission status: Accepted

Solution code:
X = int(input())

ans = 1

for a in range(1,X):
    for b in range(2,10):
        if a**b > X:
            break
        else:
            ans = max(ans,a**b)

    
print(ans)

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())
a = []
for i in range(1,min(x+1,33)) :
	for j in range(2, 11) :
		if i**j <= x and not i**j in a :
			a.append(i**j)
print(max(a))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
if n<=3:
  print(1)
else:
  ans=[]
  for i in range(2,int(n**(1/2)+1)):
    e=2
    while i**e<=n:
      if i**(e+1)>n:
        ans.append(i**e)
        break
      e+=1
  print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
pp = [
    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
]
pp.append(X)
pp.sort(reverse=True)
for i in range(len(pp) - 1):
    if pp[i] == X:
        print(pp[i + 1])
        break

Submission status: Accepted

Solution code:
def is_perfect_power(n):
    return n in {
        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
    }


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

Submission status: Accepted

Solution code:
def is_perfect_power(n):
    if n == 1:
        return True
    div = 2
    divs = []
    while n != 1:
        if n % div == 0:
            n //= div
            divs.append(div)
        else:
            div += 1
    divs_d = {d: 0 for d in set(divs)}
    for d in divs:
        divs_d[d] += 1
    divs_s = {n for n in divs_d.values()}
    if min(divs_s) > 1:
        for d in divs_s:
            if d % min(divs_s) != 0:
                return False
    else:
        return False
    return True


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

Submission status: Accepted

Solution code:
X = int(input())
T = []

for i in range(int(X ** (1 / 2) + 1)):
    for j in range(int(X ** (1 / 2) + 1)):
        if i ** j <= X:
            T.append(i ** j)
            
T.sort()
print(T[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

m = 0
for b in range(1, 100):
    for p in range(2, 100):
        bp = b ** p
        if bp > X:
            break
        m = max(m, bp)
print(m)

Submission status: Accepted

Solution code:
x = int(input())
num = []
for i in range(50):
    for j in range(2,10):
        if i**j <=1000 and i**j not in num:
                num.append(i**j)
        elif i**j >1000:
            break
num = sorted(num)

index = [i for i in range(len(num)) if num[i]<=x][-1]
print(num[index])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

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

print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(X: int):
    if X == 1:
        print(1)
        return

    res = 0
    for b in range(X):
        for p in range(2,10):
            xx =  b**p 
            if xx == X:
                print(xx)
                return
            elif xx < X:
                res = max(res,xx)
            else:
                break

    print(res)
        


# 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:
X = int(raw_input())
lst = [1]
for i in range(2, 32):
	a = i*i
	while a <= X:
		lst.append(a)
		a *= i
lst.sort()
print lst[-1]

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
for i in range(1, int(X ** 0.5) + 1):
    n = i
    if n == 1:
        ans = 1
        continue
    while n * i <= X:
        n *= i
    if n != i:
        ans = max(ans, n)
print(ans)

Submission status: Accepted

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

# 最大値（1のべき乗数で初期化）
mx=1

# 2〜1000
for a in range(2,1000):

  i=2
  while True:
    # べき乗
    b=pow(a,i)

    # X以下の場合、最大値保存
    if b<=X:
      mx=max(mx,b)
    else:
      # Xをオーバーした場合はループを抜ける
      break

    i+=1

# 最大値を出力
print(mx)

Submission status: Accepted

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

# Xが1の場合は答えは1
if X==1:
  print(1)
  exit()

# 最大値
mx=0

# 2〜1000
for a in range(2,1000):

  i=2
  while True:
    # べき乗
    b=pow(a,i)

    # X以下の場合、最大値保存
    if b<=X:
      mx=max(mx,b)
    else:
      # Xをオーバーした場合はループを抜ける
      break

    i+=1

# 最大値を出力
print(mx)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
X = int(input())
L = [1]
for v in range(2, math.floor(math.sqrt(X))+1):
  x = v
  while True:
    x *= v
    if x > X:
      break
    L.append(x)
print(max(L))

Submission status: Accepted

Solution code:
import math
n = int(input())
res = [1]
last = -1
for i in range(1, n):
    for c in range(2, n):
        num = pow(i, c)
        if num == last:
            break
        if num <= n:
            res.append(num)
        else:
            break
        c+= 1
        last = num
print(max(res))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

    inf = 10 ** 10
    ans = 1
    for b in range(2, inf):
        for p in range(2, inf):
            kari = b ** p
            if kari > num:
                break
            if kari <= num and kari > ans:
                ans = kari
        if b ** 2 > num:
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())
g = 1
for i in range(2,int(X**0.5)+1):
    j = 2
    while i**j <= X:j += 1
    g = max(g,i**(j-1))
else:print(g)

Submission status: Accepted

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

if x == 1:
    print(1)
else:
    b = 2
    while b**2 <= x:
        p = 2
        while b**p <= x:
            list_.append(b**p)
            p += 1
        b += 1
    print(max(list_))

Submission status: Accepted

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

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(ans, i**j)

print(ans)

Submission status: Accepted

Solution code:
import math

X = int(input())
ans = 1
if X != 1:
  for b in range(2, int(math.sqrt(X)) + 1):
    p = 2
    while b ** p <= X:
      ans = max(ans, b ** p)
      p += 1
print(ans)

Submission status: Accepted

Solution code:
#平方根を求める
def sqrt(n):
    a = n/2
    while True:
        b = (a+n/a)/2
        if a == b:return b
        else:a,b = b,a


#べき乗数かどうか判断する関数
def pow_judge(n):
    if n == 1 or n == 2:return True
    i = int(sqrt(n))
    if i*i == n:
        return True
    else:
        return False

ls = set()
for i in range(1,32):
    for j in range(2,11):
        if i**j > 1000:break
        ls.add(i ** j)
x = int(input())
for i in range(x,-1,-1):
    if i in ls:
        print(i)
        break

Submission status: Accepted

Solution code:
import sys

X = int(input())

for i in reversed(range(1, X + 1)):
    for j in range(1, i + 1):
        for k in range(2, i + 10):

            num = j ** k

            if num == i:
                print(num)
                sys.exit()

            if num > i:
                break

Submission status: Accepted

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


def solve(X: int):
    i = 2
    vals = [1]
    while i * i <= X:
        tmp = i
        while tmp <= X:
            #print(tmp)
            vals.append(tmp)
            tmp *= i
        i += 1
    vals.sort()
    ret = vals[-1]
    print(ret)
    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())

ans = 1

for i in range(2,int(1000**0.5)+1):
    cnt = 2
    while True:
        s = i**cnt
        if s > x:
            break
        cnt += 1
        ans = max(s,ans)

print(ans)

Submission status: Accepted

Solution code:
beki = [1]
def get_beki(n):
    for i in range(2,n):
        for j in range(2,n):
            if i**j > n:
                break
            beki.append(i**j)

X = int(input())
get_beki(X)
print(max(beki))

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for i in range(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 = 0
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 = 0
for i in range(1, 32):
    for j in range(2, 10):
        if (i ** j <= x) and (i ** j >= ans):
            ans = i ** j
print(ans)

Submission status: Accepted

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    x = intin()

    ans = 1

    for i in range(2, x + 1):
        for j in range(2, 999999):
            k = i**j
            if k > x:
                break
            ans = max(ans, k)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())
i = 2
A = [0 for _ in range(X+1)]
A[1] = 1
while i**2 <= X:
  A[i**2] = i**2
  p = 3
  while i**p <= X:
    A[i**p] = i**p
    p += 1
  i += 1
print(max(A))

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    x = f()[0]
    a = [0]*10001

    a[1] = 1
    for i in range(2,1000):
        if i*i <= 1000:
            a[i*i] = 1
            k = 3
            while i**k <= 1000:
                a[i**k] = 1
                k += 1
        else:
            break

    for i in range(x, 0, -1):
        if a[i] == 1:
            print(i)
            break


solve()

Submission status: Accepted

Solution code:
n = int(input())
b = 2
p = 2
max_n = 1
while True:
    power = b**p
    if power <= n:
        max_n = max(power, max_n)
        p += 1
    else:
        p = 2
        b += 1
    if b == 33:
        break
print(max_n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
y=1
for i in range(x+1):
    for j in range(35):
        for k in range(2,10):
            if i==j**k:
                y=max(y,i)
print(y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())
A=[]
for k in range(X):
    x=X-k
    for i in range(2,10):
        if float.is_integer(x**(1/i)):
            A.append(x)
        else:
            continue
if X==1000:
    print(1000)
else:
    print(max(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools as its

X = int(input())

pows = []
for p in range(1, 1000+1):
    for q in range(2, 1000+1):
        n = p**q
        if n > X:
            break
        else:
            pows.append(n)

pows.sort(reverse=True)

print(pows[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
ans = [b**p for b in range(1001) for p in range(2,10)
      if b**p <= x]
print(max(ans))

Submission status: Accepted

Solution code:
X=int(input())
Y=int((X**(1/2)))

v=[1]
for i in range(2,Y+1):
    j = 2
    while(i**j<=X):
        v.append(i**j)
        j+=1
print(max(v))

Submission status: Accepted

Solution code:
x=int(input())
ans=[1] #1を入れないとエラー

for p in range(2,x+1):
    b=2
    while p**b<=x:
        ans.append(p**b)
        b+=1
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
x=int(input())
ans=0
for p in range(2,10):
    for b in range(34):
        if b**p<=x:
            ans=max(ans,b**p)
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
l=[]
for i in range(1,33):
    for j in range(2,11):
        if i**j<=1000:
            l.append(i**j)
s=sorted(list(set(l)))
for i in s:
    if x<i or x==1000:
        print(s[s.index(i)-1])
        break

Submission status: Accepted

Solution code:
import sys
import math

def isExponential(i : int) -> bool:
    for j in range(2,math.ceil(math.sqrt(i))+1):       
        devidend = i
        devisor = j
        #print(devidend,devisor,"inFor") 
        while 1:
            #print(devidend,devisor,"inWhile")
            if devidend % devisor != 0:
                break
            else:
                if devidend == devisor:
                    return True
                else:
                    devidend //= devisor
    return False

x = int(input())
if x == 1:
    print(1)
for i in range(x,0,-1):
    if isExponential(i) == True:
        print(i)
        #print("wtf")
        break

Submission status: Accepted

Solution code:
import sys
import math

def isExponential(i : int) -> bool:
    #math.ceil(math.sqrt(i))+1
    for j in range(2,i):       
        devidend = i
        devisor = j
        #print(devidend,devisor,"inFor") 
        while 1:
            #print(devidend,devisor,"inWhile")
            if devidend % devisor != 0:
                break
            else:
                if devidend == devisor:
                    return True
                else:
                    devidend //= devisor
    return False

x = int(input())
if x == 1:
    print(1)
for i in range(x,0,-1):
    if isExponential(i) == True:
        print(i)
        #print("wtf")
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  b = 2
  s = set()
  s.add(1)
  while b**2 <= N:
    p = 2
    while b**p <= N:
      s.add(b**p)
      p += 1
    b += 1

  print(max(s))


if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
x=int(input())
y=int(x**0.5)+1
ans_list=[]
for i in range(y):
    for j in range(10):
        if i**j<=x:
            ans_list.append(i**j)
ans_list.sort()
print(ans_list[-1])

Submission status: Accepted

Solution code:
x=int(input())

max=0
for i in range(x+1):
    for j in range(2, 10):
        #print(i,j)
        if i**j <= x:
            if max < i**j:
                #print(i,j)
                max=i**j

print(max)

Submission status: Accepted

Solution code:

import math

def read_input():
    x = int(input())
    return x


def submit():
    x = read_input()
    max_root = int(math.floor(math.sqrt(x)))

    max_square = 1
    for i in range(2, max_root + 1):
        test = i
        while test <= x:
            if test > max_square:
                max_square = test
            test *= i

    print(max_square)


if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
ls = [1]
for i in range(2, 32):
    if i in ls:
        continue
    temp = i ** 2
    while temp <= 1000:
        ls.append(temp)
        temp *= i
ls.sort(reverse=True)

x = int(input())
print([i for i in ls if i <= x][0])

Submission status: Accepted

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

print(max)

Submission status: Accepted

Solution code:
X = int(input())

ans = 0
if X == 1:
    print(1)
else:
    for i in range(2, X+1):
        tmp = i
        tmp_ans = 0
        j = 2
        while tmp_ans <= X:
            tmp_ans = tmp ** j
            if tmp_ans <= X:
                ans = max(ans, tmp_ans)
            j += 1
    print(ans)