[Bronze III] Sum of Three Cubes - 27621

문제 링크

성능 요약

메모리: 32412 KB, 시간: 32 ms

분류

구현, 런타임 전의 전처리

제출 일자

2026년 04월 25일 22:04:59

문제 설명

Recently, a mathematician has just found three cube numbers that sum up to 42 using over a million hours of computing time. With this breakthrough, we have found three cube numbers that sum up to all non-negative integers less than 100 if it is possible to do so. In other words, for every 0 ≤ N < 100, we have found the triples (X, Y, Z) such that X3 + Y3 + Z3 = N, or we have proved that no such triplet exists.

The following is a table of (X, Y, Z) that satisfies X3 + Y3 + Z3 = N for 0 ≤ N < 50.

NXYZ
0000
1001
2011
3111
4No solution
5No solution
6-1-12
70-12
8002
9012
10112
11-2-23
12710-11
13No solution
14No solution
15-122
16-511-16091626
17122
18-1-23
190-23
201-23
21-11-1416
22No solution
23No solution
24-2901096694-1555055555515584139827
25-1-13
260-13
27003
28013
29113
30-283059965-22188885172220422932
31No solution
32No solution
338866128975287528-8778405442862239-2736111468807040
34-123
35023
36123
370-34
381-34
39117367134476-159380
40No solution
41No solution
42-805387388120759748043575814581751512602123297335631
43223
44-5-78
452-34
46-233
4767-8
48-23-2631
49No solution

Reading a long table is a tedious job, so you would like to create a program that takes N as an input, and produce X, Y, Z as the output. The value of X, Y, and Z must be an integer not less than −1018 and not more than 1018.

입력

Input begins with a line containing an integer: N (0 ≤ N < 50).

출력

Output in a line three integers (separated by a single space): X Y Z that satisfies the condition given in the problem statement. If there is more than one solution, you can output any of them. If there is no solution, output 0 instead.


💡 해결 방법

💻 코드

# 문제
# Recently, a mathematician has just found three cube numbers that sum up to 42 using over a million hours of computing time. With this breakthrough, we have found three cube numbers that sum up to all non-negative integers less than 100 if it is possible to do so. In other words, for every 0 ≤ N < 100, we have found the triples (X, Y, Z) such that X3 + Y3 + Z3 = N, or we have proved that no such triplet exists.
 
# The following is a table of (X, Y, Z) that satisfies X3 + Y3 + Z3 = N for 0 ≤ N < 50.
 
# N	X	Y	Z
# 0	0	0	0
# 1	0	0	1
# 2	0	1	1
# 3	1	1	1
# 4	No solution
# 5	No solution
# 6	-1	-1	2
# 7	0	-1	2
# 8	0	0	2
# 9	0	1	2
# 10	1	1	2
# 11	-2	-2	3
# 12	7	10	-11
# 13	No solution
# 14	No solution
# 15	-1	2	2
# 16	-511	-1609	1626
# 17	1	2	2
# 18	-1	-2	3
# 19	0	-2	3
# 20	1	-2	3
# 21	-11	-14	16
# 22	No solution
# 23	No solution
# 24	-2901096694	-15550555555	15584139827
# 25	-1	-1	3
# 26	0	-1	3
# 27	0	0	3
# 28	0	1	3
# 29	1	1	3
# 30	-283059965	-2218888517	2220422932
# 31	No solution
# 32	No solution
# 33	8866128975287528	-8778405442862239	-2736111468807040
# 34	-1	2	3
# 35	0	2	3
# 36	1	2	3
# 37	0	-3	4
# 38	1	-3	4
# 39	117367	134476	-159380
# 40	No solution
# 41	No solution
# 42	-80538738812075974	80435758145817515	12602123297335631
# 43	2	2	3
# 44	-5	-7	8
# 45	2	-3	4
# 46	-2	3	3
# 47	6	7	-8
# 48	-23	-26	31
# 49	No solution
# Reading a long table is a tedious job, so you would like to create a program that takes N as an input, and produce X, Y, Z as the output. The value of X, Y, and Z must be an integer not less than −1018 and not more than 1018.
 
# 입력
# Input begins with a line containing an integer: N (0 ≤ N < 50).
 
# 출력
# Output in a line three integers (separated by a single space): X Y Z that satisfies the condition given in the problem statement. If there is more than one solution, you can output any of them. If there is no solution, output 0 instead.
 
# 예제 입력 1 
# 2
# 예제 출력 1 
# 3737830626090 1490220318001 -3815176160999
# Other answers such as X = 1214928, Y = 3480205, and Z = −3528875 are also accepted.
 
# 예제 입력 2 
# 5
# 예제 출력 2 
# 0
 
 
 
ans = '''0	0	0	0
1	0	0	1
2	0	1	1
3	1	1	1
4	No solution
5	No solution
6	-1	-1	2
7	0	-1	2
8	0	0	2
9	0	1	2
10	1	1	2
11	-2	-2	3
12	7	10	-11
13	No solution
14	No solution
15	-1	2	2
16	-511	-1609	1626
17	1	2	2
18	-1	-2	3
19	0	-2	3
20	1	-2	3
21	-11	-14	16
22	No solution
23	No solution
24	-2901096694	-15550555555	15584139827
25	-1	-1	3
26	0	-1	3
27	0	0	3
28	0	1	3
29	1	1	3
30	-283059965	-2218888517	2220422932
31	No solution
32	No solution
33	8866128975287528	-8778405442862239	-2736111468807040
34	-1	2	3
35	0	2	3
36	1	2	3
37	0	-3	4
38	1	-3	4
39	117367	134476	-159380
40	No solution
41	No solution
42	-80538738812075974	80435758145817515	12602123297335631
43	2	2	3
44	-5	-7	8
45	2	-3	4
46	-2	3	3
47	6	7	-8
48	-23	-26	31
49	No solution'''
 
ans = ans.split("\n")
ans  = [line.split() for line in ans]
#print(ans)
 
n = input()
 
for i in ans:
    if i[0] == n:
        if i[1] != "No":
            print(*i[1:], sep = ' ')
        else:
            print(0)
        quit()