PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def sumofsq(a):
b,ss=[],[]
sq=[x*x for x in range(1,int(a**0.5+1))]
d={}
for x in sq:
for y in sq:
d[(x+y)]=(x,y)
for s in sq[::-1]:
temp=a-s
b.append((sq.index(s)+1))
while temp>0:
if temp in d:
k,l =d[temp]
b.append(sq.index(l)+1)
b.append(sq.index(k)+1)
temp=temp-k-l
else:
c=int(temp**0.5)
b.append(c)
temp=temp-(c*c)
ss.append(sorted(b))
b=[]
return([list(item) for item in set(tuple(row) for row in ss)])
a=int(input())
sos=sumofsq(a)
losos=[len(x) for x in sos]
for row in sos:
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run