Problem:


Score : 200 points

Problem Statement

You are given a positive integer X.
Find the largest perfect power that is at most X.
Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Constraints

1 ≤ X ≤ 1000

X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

Print the largest perfect power that is at most X.

Sample Input 1

10

Sample Output 1

9

There are four perfect powers that are at most 10: 1, 4, 8 and 9.
We should print the largest among them, 9.

Sample Input 2

1

Sample Output 2

1

Sample Input 3

999

Sample Output 3

961



Sample input:
10


Sample output:
9

Submission status: Accepted

Solution code:
x = int(input())

ans = 0
for i in range(1, 100):
    for j in range(2, 100):
        y = pow(i, j)
        if y <= x:
            ans = max(ans, y)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def check_p(X,b):
	p = 0
	while b**(p+1) <= X:
		p+=1
	return b**p

ans=1
for b in range(2,int(math.sqrt(X))+1):
	ans = max(ans,check_p(X,b))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
X = int(input())
list1 = []

for i in range(2,X+1):
  for j in range(2,int((X + 1)/2)):
    a = math.log10(i)/math.log10(j)
    if a.is_integer():
      list1.append(i)
if list1 == []:
  print(1)
else:
  print(max(list1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from bisect import *
A = {1}
for p in range(2,11):
    for b in range(2,33):
        A.add(b**p)
A = list(A)
A.sort()
X = int(input())
print(A[bisect_right(A,X)-1])

Submission status: Accepted

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

Submission status: Accepted

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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	x=II()

	li=set([1])

	for i in range(2,35):
		for j in range(2,11):
			if i**j<=1001:
				li.add(i**j)
			else:
				break

	li=list(li)
	li.sort(reverse=True)

	#print(li)

	for i in li:
		if i<=x:
			print(i)
			exit()










if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
X=int(input())
max = 1
for i in range(2,33):
    k = 2
    while True:
        n = i**k
        if n > X:
            break
        if n > max:
            max = n
        k += 1
print(max)

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    maxi = 1
    if X <= 2:
        print(1)
        return
    for b in range(2, X):
        for p in range(2, X):
            if b**p > X:
                break
            else:
                maxi = max(maxi, b**p)
    print(maxi)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
x = I()
ans = -1
for b in range(1,x+2):
    for p in range(2, x+2):
        if b**p > x:
            break
        ans = max(ans, b**p)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
print(max([pow(i, j) for i in range(1, 32)
           for j in range(2, 10) if pow(i, j) <= n]))

Submission status: Accepted

Solution code:
import math
X = int(input())
beki = []
beki.append(1)
Xruto = math.sqrt(X)
Xruto = math.floor(Xruto)
for i in range(2, Xruto+1):
    for j in range(10):
        a = pow(i, j)
        if a <= X:
            beki.append(a)
        else:
            break
print(max(beki))

Submission status: Accepted

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ans = 1
for i in range(X):
  Y = X - i
  f = collections.Counter(prime_factorize(Y))
  if len(set(f.values())) == 1 and list(f.values())[0] > 1 :
    ans = Y
    break
print(ans)

Submission status: Accepted

Solution code:
from bisect import bisect_right


cands = []
for i in range(2, 400):
    cur = i
    while cur * i <= 1000:
        cands.append(cur * i)
        cur *= i
cands.sort()

X = int(input())
if X == 1:
    print(1)
else:
    print(cands[bisect_right(cands, X) - 1])

Submission status: Accepted

Solution code:
x = int(input())
ans = [1]
for i in range(2, 1001):
    p = 2
    while i**p <= x:
        ans.append(i**p)
        p += 1
ans.sort(reverse=True)
#print(ans)
print(ans[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
for i in range(33):
    for j in range(2,11):
        if pow(i,j) > x: break
        ans = max(ans,pow(i,j))

print(ans)

Submission status: Accepted

Solution code:
X = int(input())

max_expo = 1

for p in range(2,10):
  for b in range(X):
    if max_expo < (b**p) <= X:
      max_expo = (b**p)
print(max_expo)

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())
ex = [0 for i in range(1001)]
ex[1] = 1

for i in range(2, 1001):
  tmp = i * i
  while tmp <= 1000:
    ex[tmp] = 1
    tmp *= i
  
for i in range(x, 0, -1):
  if ex[i] == 1:
    print(i)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
ans = 0
i = 1
while i*i <= a:
  for j in range(1, 1000):
    if i**j <= a and ans < i**j:
      ans = i**j
    if i**j > a:
      break;
  i += 1
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

beki = {1}
for b in range(2,32):
    for p in range(2,10):
        if b**p<=x:
            beki.add(b**p)
        else:
            break
            
beki = sorted(beki)
            
print(beki.pop(-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

if x <= 3:
  print(x)
  exit()

ans = 0
for i in range(2, int(x**0.5)+1):
  s = i
  t = 1
  while s < x:
    t += 1
    s = i**t
    if ans < s and s <= x: ans = s
print(ans)

Submission status: Accepted

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

A=[1]
for b in range(2,32):
  for p in range(2,10):
    if b**p>X:
      break
    elif b**p not in A:
      A.append(b**p)
print(max(A))

Submission status: Accepted

Solution code:
X = int(input())

l = [1]

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

Submission status: Accepted

Solution code:
import math

x = int(input())

k = int(math.sqrt(x))

l = [1]

for i in range(2, k+1):
    j = 2
    while i ** j <= x:
        l.append(i ** j)
        j += 1

print(max(l))

Submission status: Accepted

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

ans = 1

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

Submission status: Accepted

Solution code:
x = int(input())

li = [1]
for i in range(2,32):
    cnt = 2
    while i**cnt<=x:
        li += [i**cnt]
        cnt +=1

print(max(li))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())

ans=0

for b in range(1, int(x**(1/2)+1)):
    for p in range(2, 20):
        c = b**p
        if c<=x:
            ans=max(ans, c)

print(ans)

Submission status: Accepted

Solution code:
import math
X=int(input())
x=int((X**(1/2))//1)
A=[]
y=int(math.log2(X)//1)
for i in range(x+1):
    for j in range(y+1):
        if i**j<=X:
            A.append(i**j)
print(max(A))

Submission status: Accepted

Solution code:
#B - Exponential
import math
X = int(input())
def expo(x):
    ans = 1
    for i in reversed(range(1,x+1)):
        for j in range(int(math.sqrt(x))+1):
            for k in range(2,int(math.sqrt(x))):
                if i == j**k:
                    ans = i
                    return ans
    return ans
print(expo(X))

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    x = I()
    flag = [False]*(x+1)
    flag[1] = True
    for b in range(1, x+1):
        for p in range(2, x+1):
            temp = b**p
            if temp > x:
                break
            flag[temp] = True
    for i in range(x, 0, -1):
        if flag[i]:
            print(i)
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import *
x=int(input())
ans=[]
if x<4:
    print(1)
    exit()
for i in range(2,int(sqrt(x))+1):
    t=2
    while i**t<=x:
        ans.append(i**t)
        t+=1
print(max(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = int(input())

ans = 1
for i in range(2, 32):
    ans_tmp = 1
    while(1):
        # print(ans_tmp**i)
        if (ans_tmp+1)**i <= x:
            ans_tmp += 1

        else:
            break
    ans = max(ans, ans_tmp**i)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

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

for b in range(1, int(x**0.5 + 1)):
    for p in range(2, 11):
        if b**p > x:
            break
        r = max(r, b**p)
        
print(r)

Submission status: Accepted

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    x = ni()
    d = x
    ans = 1
    for i in range(2, 33):
        j = 2
        while pow(i, j) <= x:
            if d > x - pow(i, j):
                ans = pow(i, j)
                d = x - pow(i, j)
            j += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())

X = I()
A = [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]
for i in range(40,-1,-1):
    if A[i] <= X:
        print(A[i])
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
min = 10000
for i in range(1,1000):
	for j in range(2,40):
		if x-i**j < min and 0 <= x-i**j:
			min = x-i**j
print(x-min)

Submission status: Accepted

Solution code:
n = int(input())
if  n == 1 or n == 2 or n == 3:
    print(1)
    exit()
while n > 0:
    for i in range(n):
        for j in range(2, 10):
            if n == i**j:
                print(n)
                exit()
    n -= 1

Submission status: Accepted

Solution code:
X = int(input())
check =[]
check2=[]
for i in range(1,33):
    for s in range(2,11):
        check.append(pow(i,s))

#print(check)
for i in check:
    if i<=X:
        check2.append(i)
print(max(check2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())

ans = 0
for i in range(1, 101):
    for j in range(2, 101):
        if i ** j <= X:
            if i ** j > ans:
                ans = i ** j
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ans=[]
for i in range(1,32):
  for k in range(2,11):
    c=i**k
    if c<=N:
      ans.append(c)
print(max(ans))

Submission status: Accepted

Solution code:
import math

X = int(input())

ans_list = []

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

Submission status: Accepted

Solution code:
X = int(input())
ans = [False] * (X+1)
ans[1] = True
for i in range(2, X):
    for j in range(2, X):
        if i**j <= X:
            ans[i**j] = True
        else:
            break
for i in range(X, 0, -1):
    if ans[i]:
        print(i)
        break

Submission status: Accepted

Solution code:
from math import sqrt
x = int(input())
l = []
if x == 1:
    print(1)
    exit()
for i in range(1, int(sqrt(x))+1):
    for j in range(2, x+1):
        if 1 <= i**j <= x:
            l.append(i**j)
print(max(l))

Submission status: Accepted

Solution code:
n=(int)(input())
a=[1]
for i in range(2, n):
  temp = i ** 2
  while(temp <= n):
    a.append(temp)
    temp *= i
a = sorted(set(a))
#print(a)
print(list(i for i in a if i <= n)[-1])

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

x = inint()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
for b in range(1,x):
    for p in range(2,x):
        a = b**p
        if a == a // 1 and a > ans and a <= x:
            ans = a
        if a>x:
            break
    if a > x:
        continue
print(ans)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 097
# B - Exponential

X=int(input())

ans = 1

for i in range (1,X):
    for j in range (2,X):
        a=i**j
        if a==a//1 and a > ans and a<=X :
            ans=a
        if a>X:
            break
    if a>X:
        continue
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

x = int(input())

ans = 1

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

Submission status: Accepted

Solution code:
def main():
    X = int(input())
    if X <= 3:
        print(1)
        return
    
    ans = 0
    for n in range(2, X):
        p = 2
        while pow(n, p) <= X:
            if ans < pow(n, p):
                ans = pow(n, p)
            p += 1
    print(ans)
    
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect

x = int(input())

s = {1}
for a in range(2, 1000):
    for b in range(2, 11):
        c = a ** b
        if c > 1000:
            break
        s.add(c)
s = sorted(s, reverse=True)
for a in s:
    if a <= x:
        print(a)
        exit(0)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X = int(readline())

    if X <= 3:
        print(1)
        return

    ans = 0
    for n in range(2, X):
        p = 2
        while pow(n, p) <= X:
            if ans < pow(n, p):
                ans = pow(n, p)
            p += 1

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

X = int(input())

ans = 1
for i in range(2, X):
    b = i
    p = 2
    a = b ** p
    while a <= X: 
        ans = max(ans, a)
        p += 1
        a = b ** p
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

M = int(X**.5) + 1

ans = 1

for i in range (2, M):
    for j in range(2, 10):
        if X < i**(j+1):
            ans = max(ans, i**j)
            break

print(ans)

Submission status: Accepted

Solution code:
x=int(input())
r=1
for b in range(2,int(x**.5)+1):
  for p in range(2,11):
    if b**p>x: break
    r=max(r,b**p)
print(r)

Submission status: Accepted

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

Submission status: Accepted

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

def expo(x,i):
    while x % i == 0:
        x = x//i
    if x == 1:
        return True
    else:
        return False

if x > 4:
    while x >1:
        for j in range(2,int(math.sqrt(x))+1):
            if expo(x, j) == True:
                print(x)
                break
        if expo(x,j) == True:
            break
        else:
            x -= 1
else:
    print(1)

Submission status: Accepted

Solution code:
p = []
p.extend([i ** 2 for i in range(int(1000**(1/2)) + 1)])
p.extend([i ** 3 for i in range(int(1000**(1/3)) + 1)])
p.extend([i ** 5 for i in range(int(1000**(1/5)) + 1)])
p.extend([i ** 7 for i in range(int(1000**(1/7)) + 1)])
p.sort()
p.append(1000)
p.append(1001)
 
N = int(input())
 
for j in range(len(p) - 1):
  if p[j] <= N < p[j + 1]:
    print(p[j])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = []
tent = True
while True:
  if tent == True:
    for i in range(1,1001):
      if i ** 2 > 1000:
        tent = False
        break
      else:
        for j in range(2,10):
          if i**j <= 1000:
            a.append(i**j)
          else:
            break
  else:
    break
new_lst = [e for e in a if e <= n]
print(max(new_lst))

Submission status: Accepted

Solution code:
import math

X = int(input())

dp = [[0] * 100 for _ in range(X + 1)]

maxint = 1

for i in range(2, int(math.sqrt(X)) + 1):
    dp[i][1] = i
    for j in range(2, 100):
        dp[i][j] = dp[i][j - 1] * i
        if dp[i][j] > X:
            maxint = max(maxint, dp[i][j - 1])
            break
            

print(maxint)

Submission status: Accepted

Solution code:
A = int(input())
ans = []
for i in range(1,32):
    for j in range(2,1000):
        ans.append(i ** j)
ans.sort()
for h in range(len(ans)):
    if A < ans[h]:
        print(ans[h - 1])
        exit()

Submission status: Accepted

Solution code:
X = int(input())
if X==1:
    MAX = 1
else:
    MAX = 0
    for B in range(2,35):
        for P in range(2,15):
            if B**P>X:
                break
            else:
                if MAX<B**P:
                    MAX = B**P
print(MAX)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
ans = 1
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())
m=1
if x<=3:
    print(1)
else:
    for p in range(2,12):
        a=2
        while a**p<=x:
            m=max(m,a**p)
            a+=1
    print(m)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    X = I()

    ans = 0
    for i in range(1, int(X ** 0.5) + 1):
        for j in range(2, max(int(math.log2(X)) + 1, 3)):
            tmp = i ** j
            if tmp <= X:
                ans = max(tmp, ans)

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X=int(input())

MAX=0
for i in range(1,int(X**.5)+3):
  for j in range(2,10):
    if i**j<=X:
      if MAX < i**j:
        MAX = i**j
    else:
      break

print(MAX)

Submission status: Accepted

Solution code:
L=[1]
s=2
for i in range(2,32):
  while True:
    s=s*i
    if s<=1000:
      L.append(s)
    else:
      s=i+1
      break
L=sorted(list(set(L)))
N=int(input())
S=[i for i in L if i<=N]
print(S[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

x = int(input())

ans = 1
for i in range(2, math.ceil(math.sqrt(x)) + 1):
    y = i * i
    while y <= x:
        ans = max(ans, y)
        y *= i
print(ans)

Submission status: Accepted

Solution code:
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

import math
X = INT()
if X == 1:
    print(1)
else:
    ans = 1
    for i in range(2, int(math.sqrt(X)) + 1, 1):
        tmp = i
        while tmp <= X:
            if tmp > ans: ans = tmp
            tmp *= i
    print(ans)

Submission status: Accepted

Solution code:
X = int(input())

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

ans = 0

for b in range(2, int(X**0.5)+2):
  temp = b
  while temp <= X:
    ans = max(ans, temp)
    temp *= b

print(ans)

Submission status: Accepted

Solution code:
s = input()
x = int(s)

y = 2
max_num = 1

for i in range(2, x):
    if i > x:
        break
    z = i
    y = z * z
    for j in range(2, x):
        if y <= x:
            max_num = max(max_num, y)
        else:
            break
        y *= z

print(max_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
  ans = 0
  X = int(input())
  lis = [False]*(X+1)
  lis[1] = True
  for b in range(2,X+1):
    p = 2
    while b**p<=X:
      lis[b**p] = True
      p += 1
  for i in range(X,-1,-1):
    if lis[i]==True:
      return i
print(solve())

Submission status: Accepted

Solution code:
#素因数分解して列挙する関数、約数列挙ではない！
from collections import Counter
def factorize(n):
  b = 2
  fct = []
  while b * b <= n:
    while n % b == 0:
      n //= b
      fct.append(b)
    b = b + 1
  if n > 1:
    fct.append(n)
  f = Counter(fct).values()
  if 1 not in f and len(set(f))==1:
    return True
  return False

X = int(input())
for i in range(X,0,-1):
  f = factorize(i)
  if f==True or i==1:
    print(i)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x = I()
ma = 1
for b in range(1,x+1):
    for p in range(2,x+1):
        if b**p <= x:
            ma = max(ma,b**p)
        else:
            break
print(ma)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

x = int(input())
bekis = set()
bekis.add(1)

ans = 1
for b in range(2,35):
    for p in range(2,11):
        num = pow(b,p)
        if num <= x:
            ans = max(ans,num)
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    X = ini()
    ans = 1
    for p in range(2, X):
        a = p * p
        while a <= X:
            ans = max(ans, a)
            a *= p
    return ans


print(solve())

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for b in range(2,32):
    p = 2
    while b**p <= x:
        ans = max(ans, b**p)
        p += 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:
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)