Problem p02690 (python)

Fixed submission:

x=int(input())
A=0
B=0
for a in range(-500,500):
    for b in range(-500,500):
        if a**5-b**5==x:
            A=a
            B=b
            break
print(A,B)

Buggy submission (verdict: Runtime Error):

"""
=int(input())
=map(int,input().split())
=list(map(int,input().split()))

# アレイ import numpy as np =np.array(list(map(float,input().split())))

# 文字列 =list(str(input()).split(" " or ","))

# 一文字＆連番(縦横可能) =map(int, open(0).read().split())

# 2-d list
lis=[[] for _ in range(M)]
for i in range(M):
    lis[i] = list(map(int,input().split()[0:]))

# Each list
N = int(input())
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
"""
import numpy as np


n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

from decimal import Decimal
# print((list(pf.keys()))[0]) #素因数分解したときの最小の因数取得
lis=[]
for b in range(-1000000,1000000):
    a=b+int(list(pf.keys())[0])
    siki=Decimal(a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4)
    if siki==Decimal(x/int(list(pf.keys())[0])):
        lis.append((a,b))
print(*lis[0])

Buggy submission (verdict: Runtime Error):

"""
=int(input())
=map(int,input().split())
=list(map(int,input().split()))

# アレイ import numpy as np =np.array(list(map(float,input().split())))

# 文字列 =list(str(input()).split(" " or ","))

# 一文字＆連番(縦横可能) =map(int, open(0).read().split())

# 2-d list
lis=[[] for _ in range(M)]
for i in range(M):
    lis[i] = list(map(int,input().split()[0:]))

# Each list
N = int(input())
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
"""
import numpy as np


n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

from decimal import Decimal
# print((list(pf.keys()))[0]) #素因数分解したときの最小の因数取得
lis=[]
for b in range(-1000,1000):
    a=b+int(list(pf.keys())[0])
    siki=Decimal(a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4)
    if siki==Decimal(x/int(list(pf.keys())[0])):
        lis.append((a,b))
print(*lis[0])

Buggy submission (verdict: Runtime Error):

n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

# print((list(pf.keys()))[0]) #素因数分解したときの最小の因数取得
lis=[]
for b in range(-1000,1000):
    a=b+int(list(pf.keys())[0])
    siki=a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
    if siki==x/int(list(pf.keys())[0]):
        lis.append((a,b))
print(*lis[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

# print((list(pf.keys()))[0]) #素因数分解したときの最小の因数取得

for b in range(-1000,1000):
    a=b+int(list(pf.keys())[0])
    siki=a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
    if siki==x/int(list(pf.keys())[0]):
        print(*(a,b))

Buggy submission (verdict: Runtime Error):

n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

for b in range(-10,10):
    a=b+int(list(pf.keys())[0])
    siki=a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
    if siki==x/int(list(pf.keys())[0]):
        print(*(a,b))

Buggy submission (verdict: Runtime Error):

pf={}
n = int(input())
x=n
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

# print((list(pf.keys()))[0]) #素因数分解したときの最小の因数取得

for b in range(-10,10):
    a=b+int(list(pf.keys())[0])
    siki=a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
    if siki==x/int(list(pf.keys())[0]):
        print(*(a,b))