Translate

Views

Monday, September 9, 2024

Solution UVA: 11428 - Cubes

 

 Problem  VerdictLangTimeBestRankSubmit Time
 | discuss11428 - Cubes AcceptedPython0.0200.00029291 mins ago

Suggest:

61^3 - 60^3 > 10000 so x_max <= 60


r = {}
for x in range(1, 61):
    for y in range(1, x):

        if x**3-y**3 in r:
       
            u, v = r[x**3-y**3]
            if (v > y):
                r[x**3-y**3] = (x,y)
       
        else:
           
            r[x**3-y**3] = (x,y)
while True:
    n = int(input())
    if n == 0:
        break
    if n not in r:
        print('No solution')
    else:
        x, y = r[n]
        print(f"{x} {y}")

No comments: