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:
# -*- coding: utf-8 -*-
"""
B - Exponential
https://beta.atcoder.jp/contests/abc097/tasks/abc097_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(X):
    ans = 1
    for i in range(1, X+1):
        for j in range(2, X+1):
            t = i**j
            if t <= X:
                ans = max(ans, t)
            else:
                break
    return ans


def main(args):
    X = int(input())
    ans = solve(X)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

maxs = []
for i in range(x):
    max = 0
    for j in range(x):
        if (i+1) ** (j+2) <= x:
            max = (i+1) ** (j+2)
            maxs.append(max)
        else:
            if j == 0:
                max = (i+1) ** (j+2)
                break
    # else:
    #     maxs.append(max)


maxs.sort()
# print(maxs)
print(maxs[-1])

Submission status: Accepted

Solution code:
x = int(input())
ma = 0
for i in range(33):
    if x  < i ** 2:
        ma = (i-1) ** 2
        break
for i in range(13):
    if x <  i ** 3:
        max([ma,(i-1) ** 3])
        ma = max([ma,(i-1) ** 3])
        break
for i in range(6):
    if x < i ** 5:
        ma = max([ma, (i-1) ** 5])
        break
print(ma)

Submission status: Accepted

Solution code:
X = int(input())
 
l = [1 for i in range(1001)]
k = 0
for i in range(1,33):
    for j in range(2,10):
        tmp = i ** j
        if tmp <= 1000:
            l[k] = tmp
            k += 1
        else :
            break
 
l.sort()
for i in range(1001):
    if X < l[i]:
        print(l[i-1])
        break
else :
    print(l[-1])

Submission status: Accepted

Solution code:
import math

x = int(input())
ans = 1

for i in range(int(math.sqrt(x)), 1, -1):
    tans = i
    while tans <= x:
        tans *= i
        if tans == x:
            print(tans)
            exit()
        else:
            continue
    ans = max(ans, tans//i)

print(ans)

Submission status: Accepted

Solution code:
X = int(input())
 
score = 0
half_x = round(X/2)
 
answer = 0
 
if X <= 3:
    print(1)
 
elif X <= 7:
    print(4)
 
else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

Submission status: Accepted

Solution code:
x = int(input())

num = list(range(2,32))

ans = 1
for i in range(len(num)):
  now = num[i]
  while now < x:
    now = now*num[i]
    if(now <= x and ans <= now):
      ans = now
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
if x == 1:
  print(x)
else:
  L = [n**k for n in range(1, x//2) for k in range(2, 10) if n**k<=x]
  print (max(L))

Submission status: Accepted

Solution code:
X = int(input())
 
score =0
half_x = round(X/2)
 
answer = 0
 
if X < 3:
    print(1)
 
elif X <= 7:
    print(4)
 
else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

Submission status: Accepted

Solution code:
import math
x=int(input())
log_x=int(math.log(x,2))
cand=[0 for i in range(1001)]
cand[0]=1
for i in range(2,1000):
    cand[i]=int(pow(x,1.0/i))**i
cand[1000]=1000
print(max(cand[:x+1]))

Submission status: Accepted

Solution code:
X = int(input())
 
score =0
half_x = round(X/2)
 
answer = 0
 
if X < 3:
    print(1)
 
elif X <= 8:
    print(4)
 
else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

Submission status: Accepted

Solution code:
x = int(input())

def is_power(a, b):
  while a % b == 0:
    a = a / b
  if a == 1:
    return True
  return False

def is_perfect_power(n):
    for i in range(n//2, 1, -1):
        if is_power(n, i):
            return True
    return False

ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
import sys
x = int(raw_input())
# a = [int(raw_input()) for i in xrange(n)]
# a,b,c,d = map(int, raw_input().split())

p = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def isPowerOfTwo(n):
    return (n > 0) and (n & (n - 1) == 0)

# s = raw_input()
# k = int(raw_input())


# print "".join(["a","b"])

# print "Yes" if 3 > 0 else "No"
if x < 4:
    print 1
    sys.exit()

X = x

while x > 1:
    n = x

    if isPowerOfTwo(x) == True:
        print x
        sys.exit()
    if x == 2 or x in p:
        x-=1
        continue
    for i in xrange(3,X):
        n = x
        c = 0
        while True:
            if n % i != 0:
                break
            n /= i
            c += 1
            if n == 1 and c > 1:
                print x
                sys.exit()
    x-=1
print 1

Submission status: Accepted

Solution code:
def check(n):
    m = 2
    dic = {}
    while n > 1:
        if n%m == 0:
            while n%m == 0:
                if m in dic:
                    dic[m] += 1
                else:
                    dic[m] = 1
                n //= m
        m += 1
    lis = []
    for i in dic.values():
        lis.append(i)
    if len(set(lis)) == 1 and lis[0] != 1:
        return True
    else:
        return False
x = int(input())
if x == 1 or x == 2 or x == 3:
    print(1)
    quit()
for i in range(x+1):
    if check(x-i):
        print(x-i)
        quit()

Submission status: Accepted

Solution code:
from math import sqrt
x = int(input())
x2 = int(sqrt(x))
ans = 1
for i in range(x2):
  for k in range(x2-1):
    tmp = (i+1)**(k+2)
    if tmp<=x and ans<=tmp:
      ans = tmp
print(ans)

Submission status: Accepted

Solution code:
inputX = int(input())
maxNumber = 1
if inputX <= 3:
    maxNumber = 1
else:
    for i in range(2, 33):
        if i== 2:
            for i1 in range(2, 10):
                if i ** i1 <= inputX:
                    if i ** i1 > maxNumber:
                        maxNumber = i ** i1
        elif i == 3:
            for i1 in range(2, 7):
                if i ** i1 <= inputX:
                    if i ** i1 > maxNumber:
                        maxNumber = i ** i1
        elif i <= 5:
            for i1 in range(2, 5):
                if i ** i1 <= inputX:
                    if i ** i1 > maxNumber:
                        maxNumber = i ** i1
        elif i <= 10:
            for i1 in range(2, 4):
                if i ** i1 <= inputX:
                    if i ** i1 > maxNumber:
                        maxNumber = i ** i1
        else:
            if i ** 2 <= inputX:
                if i ** 2 > maxNumber:
                    maxNumber = i ** 2


print (maxNumber)

Submission status: Accepted

Solution code:
import math
xx = input()
 
xs = sorted(list(set([ b ** p for b in range(1,33) for p in range(2,33) if b ** p <= 1000])))

print max([x for x in xs if x <= xx])

Submission status: Accepted

Solution code:
x = int(input())

m = 1
for i in range(1, x):
    for j in range(2, x):
        k = pow(i, j)
        if k <= x:
            m = max(k, m)
        else:
            break

print(m)

Submission status: Accepted

Solution code:
import collections

X = int(input())

def soin(x):
    li = []
    a = 2
    while x >= a * a:
        if x % a == 0:
            li.append(a)
            x //= a
        else:
            a += 1

    li.append(x)
    return(li)


for i in range(X + 1)[::-1]:
    li = soin(i)
    c = list(collections.Counter(li).values())
    if list(set(c)) == [1]:
        continue
    if len(list(set(c))) == 1:
        print(i)
        break

else:
    print(1)

Submission status: Accepted

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

a = []
b = []
for i in range(8):
    a.append(math.floor(math.pow(x,(1.0/(i+2)))))

for i in range(8):
    b.append(math.pow(a[i],(i+2)))
tmp = 0
for i in range(8):
    if tmp < b[i]:
        tmp = b[i]
if x != 1000:
    print(math.floor(tmp))
else:
    print(1000)

Submission status: Accepted

Solution code:
import numpy as np

X = int(input())
#print(X)


def MaxPow(X):
    Max = 1

    if int(np.sqrt(X)) ==1:
        return Max
    
    for b in range(2,int(np.sqrt(X))+1):
        #print(np.log(X)/np.log(b))
        for p in range(2,int(np.log(X)/np.log(b))+2):
            tmp = b**p
            if tmp<=X:
                Max = max(Max,tmp)
    return Max

print(MaxPow(X))


# for i in range(1000):
#     print(MaxPow(i))

Submission status: Accepted

Solution code:
X = int(raw_input())
  
result = 0

arr = []
for i in range(1,1001):
    for j in range(2,11):
        if i**j <= 1000:
            arr.append(i**j)
for k in arr:
    if k <= X and k >= result:
        result = k
print(result)

Submission status: Accepted

Solution code:
x = int(input())
ans = []
i = 2
while i < 10:
    t = 0
    while t <= x:
        if t ** i > x:
            break
        ans.append(t**i)
        t += 1
    i += 1
print(max(ans))

Submission status: Accepted

Solution code:
import math

x = int(input())

l = [1]

for i in range(x, 0, -1):
    if math.sqrt(i).is_integer():
        l.append(i)

    for j in range(2, 20):
        if pow(i, j) <= x:
            l.append(pow(i, j))

print(max(l))

Submission status: Accepted

Solution code:

X = int(input())

maxVal1 = 0
maxVal2 = 0
maxVal3 = 0
maxVal4 = 0
maxVal5 = 0
val = 0


for i in range(33):
	if i**2 > X:
		maxVal1 = i-1
		break

for j in range(12):
	if j**3 > X:
		maxVal2 = j-1
		break

for k in range(7):
	if k**4 > X:
		maxVal3 = k-1
		break

for k in range(5):
	if k**5 > X:
		maxVal4 = k-1
		break

for k in range(4):
	if k**6 > X:
		maxVal5 = k-1
		break


maxVal = max(maxVal1**2, maxVal2**3, maxVal3**4, maxVal4**5, maxVal5**6)
print(maxVal)

Submission status: Accepted

Solution code:
X = int(input())

score =0
half_x = round(X/2)

answer = 0

if X < 3:
    print(1)

elif X <= 8:
    print(2)

else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math 

X = int(input())
A =[]
if X == 1:
    print(1)
else:
    for i in range(30):
        b = i+2
        B = math.log(X+0.01,b)
        if math.floor(B) != 1:
            A.append(b**math.floor(B))
    print(max(A))

Submission status: Accepted

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

#32^2=1024なので、2～31までで試せばいい

if X <= 3:
    print(1)
else:    
    for b in range(2,math.ceil(X**0.5)):
        p = 2
        while b**p <= X:
            p += 1
        else:
            if b**(p-1) <= X:
                maximumList.append(b**(p-1))
    print(max(maximumList))

Submission status: Accepted

Solution code:
# coding: utf-8
x = int(input())
max = 1
for b in range(1,50):
    for p in range(2,50):
        if b**p >= max and b**p <= x:
            max = b**p

print(max)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,32):
  for j in range(2,10):
    if i**j > 1000:
      break
    else:
      a.append(i**j)
a = list(set(a))
a.sort()
for i in reversed(a):
  if i <= x:
    print(i)
    break

Submission status: Accepted

Solution code:
x = int(input())
max1 = 1
for s in range(x):
  for t in range(2,10):
    if pow(s,t) > max1 and pow(s,t) <= x:
      max1 = pow(s,t)
print(max1)

Submission status: Accepted

Solution code:
import math
import numpy as np

x = int(input())
x_sqrt = math.sqrt(x)
maxlist = []

def hoge(x, x_sqrt):
    for b in range(2, x_sqrt+1):
        i = 1
        while b ** i <= x:
            i += 1
        maxlist.append(b **(i-1))
    return np.max(np.array(maxlist))

if x - x_sqrt == 0:
    print(x)
else:
    print(hoge(x, int(x_sqrt)))

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for i in range(1,11):
    for j in range(32):
        tes = (j+1)**(i+1)
        if tes <= x and tes >= ans:
            ans = tes

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
import math
flag = False
for i in range(x):
    ans = x - i
    for j in range(2,x):
        b = round(math.pow(ans, 1/j), 10)
        if b % 1 == 0:
            flag = True
            break
        elif b < 1:
            break
    if flag:
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


beki = [1]
for i in range(2,32):
    beki = beki + [pow(i,j_prime) for j_prime in range(2,11) if pow(i,j_prime) <= 1000]
beki_uniq = list(set(beki))
beki_small = max([i for i in beki_uniq if i <= N])


print(beki_small)

Submission status: Accepted

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

#sqrt = math.sqrt(x)
#floor = math.floor(sqrt)
#print(floor ** 2)

if x == 1:
    print(1)
else:
    array = []
    for b in range(1, x // 2):
        previous = 1
        for p in range(2, x // 2):
            if b ** p > x:
                break
            else:
                previous = b ** p
        array.append(previous)
    array.sort(reverse=True)
    print(array[0])

Submission status: Accepted

Solution code:
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,476,484,512,529,576,625,676,729,784,841,900,961,1000)
k = int(input())
for i in range(len(a)):
  if k == 1:
    print(1)
    break
  elif k == 1000:
    print(1000)
    break
  
  elif a[i] > k:
    print(a[i-1])
    break

Submission status: Accepted

Solution code:
n = int(input())
a = [1]
for i in range(2,32):
	a.append(i**2)
for i in range(2,11):
	a.append(i**3)
for i in range(2,6):
	a.append(i**4)
for i in [2,3]:
	a.append(i**5)
	a.append(i**6)
for i in [7,8,9]:
	a.append(2**i)

b = set(a)
a = sorted(list(b), reverse=True)
for i in range(len(a)):
	if a[i] <= n:
		print(a[i])
		break

Submission status: Accepted

Solution code:
N = int(input())
max = 1
 
x = [1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,36,216,49,343,100,1000,11**2,
12**2,
13**2,
14**2,
15**2,
16**2,
17**2,
18**2,
19**2,
20**2,
21**2,
22**2,
23**2,
24**2,
25**2,
26**2,
27**2,
28**2,
29**2,
30**2,
31**2,
]
 
for i in range(len(x)):
    if N >= int(x[i]) :
        if max < int(x[i]) :
            max = int(x[i])
print(max)

Submission status: Accepted

Solution code:
X = int(input())
a_list = []
for s in range(1, 32):
    for i in range(2, 10):
        a = s ** i
        if a > 1000:
            break
        a_list.append(a)
a2 = sorted(list(set(a_list)), reverse=True)
for n in a2:
    if n <= X:
        print(n)
        break

Submission status: Accepted

Solution code:
from math import log, floor
x = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

value = 1

while value**2 <= x:
    value += 1

value -= 1
ans = value**2
for i in range(2, value):
    for l in range(2, value):
        num = i ** l

        if num <= x and num > ans:
            ans = num
            
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

ans = 0

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

Submission status: Accepted

Solution code:
#Exponential

#入力
X = int(input())
ans = []
#計算
for j in range(2,11,1):
	for i in range(1,X+1,1):
		if pow(i,j) > X:
			ans.append(pow(i-1,j))
			break
		if pow(i,j) == X:
			ans.append(pow(i,j))
			break

print("{}".format(max(ans)))

Submission status: Accepted

Solution code:
a, = list(map(int, input().split()))
max_num = 1
for base in range(1, a+1):
    for index in range(2, a):
        ret = base ** index
        if ret <= a:
            if ret >= max_num:
                max_num = ret
        else:
            break
print(max_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
if x==1:
    print(1)
    import sys
    sys.exit()
ans=0
for b in range(2,x):
    bp=b**2
    while(True):
        if bp*b <= x:
            bp=bp*b
            continue
        elif bp <= x <bp*b:
            ans=max(ans,bp)
            break
        else:
            break
print(ans)

Submission status: Accepted

Solution code:
import bisect
s = [1]
for i in range(2, 1001):
    j = i*i
    while j <= 1000:
        s.append(j)
        j *= i

s.sort()
print(s[bisect.bisect_right(s, int(input()))-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
Max = 0
for i in range(1,33):
    for j in range(2,7):
        if i ** j <= x:
            if Max < i ** j:
                Max = i**j
print(Max)

Submission status: Accepted

Solution code:
import numpy as np
x = int(input())
num = [0]
for b in range(1, int(np.sqrt(x))+1):
    for p in range(2, 11):
        if b**p <= x:
            num.append(b**p)
        if b**p > x:
            break
print(max(num))

Submission status: Accepted

Solution code:
X = int(input())

flag = False
for x in range(X):
    for i in range(2, X-x+1):
        n = X - x
        m = 0
        while True:
            if m == 0:
                m = i
            if n % i == 0:
                n = n / i
                if n == 1 and m != X - x:
                    flag = True
                if flag:
                    break
            else:
                break
        if flag:
            break
    if flag:
        break
if flag:
    print(X - x)
else:
    print(1)

Submission status: Accepted

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

# 入力を各変数に格納
limit = int(input())

b = 2
p = 2

# 1000までのべき乗をリストに格納
num_list = [1]
while b ** p <= 1000:

	while b ** p <= 1000:
		num_list.append(b ** p)
		p += 1

	b += 1
	p = 2

# 重複削除
num_list = list(set(num_list))
# 昇順ソート
num_list.sort()

# limit以下のものを結果リストに格納
result_list = []
for num in num_list:
	if num <= limit:
		result_list.append(num)
	else:
		break

# 最後の要素を出力
print(result_list[len(result_list)-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ansList = []
for i in range(1,33):
    for j in range(2,33):
        judge = i ** j
        if(judge <=1000 and judge not in ansList):
            ansList.append(judge)
ansList = sorted(ansList)
#print(ansList)
X = int(input())
temp = 0
for l in ansList:
    if(X >= l):
        temp = l

print(temp)

Submission status: Accepted

Solution code:
x = int(input())
a = 1
for i in range(2, 10) :
    for b in range(1, 32) :
        if( b**i<=x and a<b**i ) :
            a = b**i
print("{}".format(a))

Submission status: Accepted

Solution code:
import numpy as np
X=int(input())
Y=int(np.sqrt(X))+1
max=1
for j in range(2,Y+1):
    for i in range(1,Y+1):
        if i**j<=X and i**j>max:
            max=i**j
print(max)

Submission status: Accepted

Solution code:
X=int(input())
# 2**10
ls=set([1,])
for p in range(2,10):
    b=2
    while True:
        xx=b**p
        if xx>X:
            break
        else:
            ls.add(xx)
        b+=1
print(max(ls))

Submission status: Accepted

Solution code:
x = int(input())

i = 1
p = 1

m = 1

for b in range(2, x):
    p = 1
    n = 1
    while n <= x:
        if m < n:
            m = n
        p += 1
        n = b ** p

print(m)

Submission status: Accepted

Solution code:
num=[1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,49,343,121,144,169,196,225,256,289,324,361,400,441,484,529,576,625,676,729,784,841,900,961,1000]
num.sort()
x=int(input())
ans=1
for i in range(len(num)):
    if num[i]<=x:
        ans=max(ans,num[i])
print(ans)

Submission status: Accepted

Solution code:
import bisect
import math
import itertools

def main():
    s = set([1])
    m = 1000

    for b in range(2, int(math.sqrt(m)) + 1):
        for p in itertools.count(2):
            q = b ** p
            if q > m:
                break
            s.add(q)
    
    s = list(sorted(s))
    x = int(input())

    y = bisect.bisect_left(s, x)
    if s[y] == x:
        print(x)
    else:
        print(s[y-1])

main()

Submission status: Accepted

Solution code:
# 1
# 4 8 16 32 64 128 256 512
# 9 27 81 243 729
# 14 64 256
# 25 125 625
# 36 216
# 49 343
# 64 512
# 81 729
# 100
# 121
# .. 
# 961

X = int(raw_input())

array = []
num=1
i=1
p=2
while i <= 31:
    p = 2
    while p < 9:
        tmp = pow(i, p);
        if tmp <= 1000:
            array.append(tmp)
        else:
            break

        p = p +1
    i = i+1
        
array.sort()
array.reverse()

#print array

for item in array:
    if X < item:
        continue
    else:
        print item
        break

Submission status: Accepted

Solution code:
import math

X=int(input())

y = math.sqrt(X)
y=math.floor(y)

A=1
B=[]

for i in range(1,y+1):
    for j in range(1,y+1):
        A= i** j
        if A<=X:
            B.append(A)
print(max(B))

Submission status: Accepted

Solution code:
def main():
    N = int(input())

    if N == 1:
        print(1)
        return

    ans = 0
    for b in range(1, N):
        for p in range(2, N):
            n = b ** p
            if n <= N:
                ans = max(ans, n)
            else:
                break
    print(ans)

main()

Submission status: Accepted

Solution code:
x = int(input())
ans = 0
c = 35
for i in range(c):
    for j in range(2,c):
        a = pow(i,j)
        if ans <= a <= x and isinstance(a, int):
            ans = a

print(ans)

Submission status: Accepted

Solution code:
import math

X = int(input())

n = int(math.sqrt(X))
max_numbers = [1]
for i in range(1, n):
    index = 0
    for j in range(X):
        if pow((i+1), j) > X:
            break
        index = j
    # index = int(math.log(X, i+1))
    max_numbers.append(pow((i+1), index))
    # print(pow((i+1), index))

print(int(max(max_numbers)))

Submission status: Accepted

Solution code:
#questionB
import math
X=int(input())
max=0

for b in range(int(math.sqrt(X)+1)):
    p=2
    while p<=100:
        a=b**p
        if a>X:
            break
        if max<a:
            max=a
        p=p+1
print(max)

Submission status: Accepted

Solution code:
import math
X = int(input())
N = int(math.sqrt(X))
Ans = 1
for i in range(1, N + 1):
    for j in range(2, int(math.log2(X))):
        if i ** j > X:
            break
        elif i ** j > Ans:
            Ans = i ** j
print(Ans)

Submission status: Accepted

Solution code:
x = input()
n = 0
for i in range(11):
    if i == 0 or i == 1:
        continue
    for j in range(32):
        if j**i <= x and j**i > n:
            n = j**i
print n

Submission status: Accepted

Solution code:
X=int(input())
answer=0
b=2
q=2
if X==1 or X==2 or X==3:
    print("1")
else :
    while b<X:
        while b**q<=X:
            if b**q>answer and b**q<=X:
                answer=b**q
            q+=1
        q=2
        b+=1
    print(answer)

Submission status: Accepted

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

def beki(x):
    M = 1
    for p in range(2,int(math.sqrt(x))+1):
        for b in range(1,x+1):
            tmp =  pow(b,p)
            if tmp > M and tmp <= x:
                M = tmp
    return (M)

result = beki(x)

print(result)

Submission status: Accepted

Solution code:
X=int(input())
C=-1
if (X<=1):
	print(1)
else:
	for J in range(1,X+1):
		for I in range(2,X+1):
			if pow(J,I)<=X:
				if pow(J,I)>C:
					C=pow(J,I)
			else:
				break
	print(C)

Submission status: Accepted

Solution code:
n = int(input())

ans = 1

for i in range(2,n):
    flag = 0
    num = n
    num2 = i
    while True:
        num = num/i
        if(num >= i):
            num2 = num2*i
            flag = 1
        else:
            break

    if(ans<num2 and flag == 1):
        ans=num2

print(ans)

Submission status: Accepted

Solution code:
X= int(input().strip())
tmp = 1
endflag = 10000
for j in range(2,X):
    for i in range(1,X):
        if i**j<=X and tmp<i**j and (i+1)**j>X:
            tmp = i**j
            endflag = i
            break
        elif i >= endflag:
            break
print(tmp)

Submission status: Accepted

Solution code:

list1=[1,2,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,49,343,100,1000,121]
num=input()
num=int(num)

for i in range(12,32):
    list1.append(i**2)
    i+=1
list2=[]
for j in range(len(list1)):
    if num>=list1[j]:
        list2.append(list1[j])
        j +=1
        
print(max(list2))

Submission status: Accepted

Solution code:
import math

X=int(raw_input())


r=1
for i in range(2,X):
  m = int(math.log(X, i)+10**-10)
  if m > 1 and r < i**m:
    r = i**m

print r

Submission status: Accepted

Solution code:
x=int(input())
a=[]
for i in range(1,32):
    for j in range(2,10):
        a.append(i**j)
a = sorted(a, reverse=True)
for i in range(len(a)):
    if a[i]<=x:
        print(a[i])
        break

Submission status: Accepted

Solution code:
import math

x = int(input())

#y以上の値は候補とならない
y = int(math.sqrt(x))

k_max = 1
if y >= 2:
    for i in range(2, y + 1):
        j = int(math.log10(x) / math.log10(i))
        k = i ** j
        
        
        if k > k_max:
            k_max = k
    
print(k_max)

Submission status: Accepted

Solution code:
import math

X = int(input())
sqrtX = math.floor(math.sqrt(X))
ans1 = sqrtX * sqrtX

# 解候補
anslist = [2**3, 2**5, 2**7, 2**9, 3**3, 3**5, 3**7, 5**3, 6**3, 7**3, 10**3]
ans2 = 0
for num in anslist:
    if num <= X and num > ans1: ans2 = num

print(max(ans1,ans2))

Submission status: Accepted

Solution code:
import math
X = int(input())
max = 0
for n1 in range(1, int(math.sqrt(X)) + 1):
	for n2 in range(2, 10):
		v = pow(n1, n2)
		if v > X:
			break
		if v <= X and v > max:
			max = v
print(max)

Submission status: Accepted

Solution code:
import sys
X = int(input())
ans = 1
# temp = [0,0] 
judge1=True
judge2 =True
# while i < X+1:
for i in range(1,X+1):
    judge1 =True
    j = 2
    while judge1 and j <X:
        if  i**j > X:
            if j-1 >1:
                if ans <= i**(j-1) <X :
                    ans = i**(j-1)
                    # print("a")
                    # temp = [i,j]
                # print("{0} {1}".format(i,j))
            judge1 =False
        elif i**j == X:
            if ans <= i**j:
                ans = i**j
            judge1 =False
        # print("{0} {1}".format(i,j))
                # temp=[i,j]
        j += 1        
print(ans)

Submission status: Accepted

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

if X != 1:
  for b in range(1, X+1):
    for p in range(2, X+1):
      if b ** p > X:
        break
      if b ** p > bekimax:
        bekimax = b ** p

print (bekimax)

Submission status: Accepted

Solution code:
x = int(input())

ans=1

for b in range(2, 1001):
	for p in range(2, 10):
		a = b**p
		if x < a: break
		
		ans = max(ans, a)
		
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
maximum = 1
for i in range(2,32):
  if i*i <= x and i*i > maximum:
    maximum = i*i

for i in range(2, 11):
  if pow(i,3) <= x and pow(i,3) > maximum:
    maximum = pow(i,3)

for i in range(2, 6):
  if pow(i,4) <= x and pow(i,4) > maximum:
    maximum = pow(i,4)

for i in range(2, 4):
  if pow(i,5) <= x and pow(i,5) > maximum:
    maximum = pow(i,5)

for i in range(2, 4):
  if pow(i,6) <= x and pow(i,6) > maximum:
    maximum = pow(i,6)

for i in range(7,10):
  if pow(2,i) <= x and pow(2,i) > maximum:
    maximum = pow(2,i)

print(maximum)

Submission status: Accepted

Solution code:
import math
X = int(input())
max = 0
x = math.floor(math.sqrt(X))
for b in range(x + 1):
    for p in range(x + 1):
        # print(b**p)
        if(max < b**p <= X):
            max = b**p
print(max)

Submission status: Accepted

Solution code:
def main8():
    str = input('');
    buf = str.split();
    num = int(buf[0]);
    i = 0;
    n = 1;
    kouho = []
    while(True):
        n = n + 1;
        while(True):
            i = i + 1;
            if pow(i,n) <= num and num < pow(i+1,n):
                kouho.append(pow(i,n));
                break;
        i = 0;
        if pow(2,n+1) > num:
            break;
    print(max(kouho));
if __name__ == '__main__':
    main8()

Submission status: Accepted

Solution code:

x = int(input())
c = 1
max_ = 0
for i in range(1, 100):
    for j in range(2, 100):
        if(i ** j > x):
            continue
        if(i ** j > max_):
            max_ = i ** j
print(max_)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
lis=[1,2,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,216,36,343,49,100,1000]
for i in range(11,32):
    t=i*i
    lis.append(t)
listt=list(set(lis))
listt=sorted(listt)
a=int(input())
for i in range(300):
    if a < listt[i]:
        print (listt[i-1])
        break
    elif a == listt[i]:
        print(listt[i])
        break