Problem:


Score : 300 points

Problem Statement

Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:

1 \leq x,y,z

x^2 + y^2 + z^2 + xy + yz + zx = n

Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Constraints

All values in input are integers.

1 \leq N \leq 10^4

Input

Input is given from Standard Input in the following format:

N

Output

Print N lines. The i-th line should contain the value f(i).

Sample Input 1

20

Sample Output 1

0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0

For n=6, only (1,1,1) satisfies both of the conditions. Thus, f(6) = 1.

For n=11, three triples, (1,1,2), (1,2,1), and (2,1,1), satisfy both of the conditions. Thus, f(6) = 3.

For n=17, three triples, (1,2,2), (2,1,2), and (2,2,1), satisfy both of the conditions. Thus, f(17) = 3.

For n=18, three triples, (1,1,3), (1,3,1), and (3,1,1), satisfy both of the conditions. Thus, f(18) = 3.



Sample input:
20


Sample output:
0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0

Submission status: Time Limit Exceeded

Solution code:
import math

L=input()
L=int(L)
hai=[]
i=0
for x in range(1,90):
    for y in range(1,90):
        for z in range(1,90):
            hai.append(x**2+y**2+z**2+x*y+y*z+z*x)
                
for a in range(1,L+1):
    if a not in hai:
        print("0")
    else:
        print(hai.count(a))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    ans = [0]*(n+1)
    for p in range(1,n+1):
        for i in range(1,int(p**0.5+1)):
            for j in range(1,int(p**0.5+1)):
                t = (i+j)**2-4*(i**2+j**2+i*j-p)
                if t<0:
                    continue
                k = (t**0.5-i-j)/2
                if k.is_integer() and k>0:
                    ans[p] +=1

    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math

L=input()
L=int(L)
hai=[]
i=0
for x in range(1,99):
    for y in range(1,99):
        for z in range(1,99):
            hai.append(x**2+y**2+z**2+x*y+y*z+z*x)
                
for a in range(1,L+1):
    if a not in hai:
        print("0")
    else:
        print(hai.count(a))

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

used = [[0]*3]*N

count = [0] * N


if N <= 5:
    for x in range(N):
        print(count[x])
else:
    for n in range(6,N):
        rtn = int(math.sqrt(n))
        #print(n)
        for x in range(1,rtn):
            #print(x)
            xx = x**2
            if xx <= n - 5:
                #print("xpath")
                for y in range(1,rtn):
                    #print(x,y)
                    xy = x*y
                    yy = y**2
                    ysum = xx+yy+xy
                    if ysum <= n-3:
                        #print("ypath")
                        for z in range(1,rtn):
                            #print(x,y,z)
                            zz = z**2
                            xz = x*z
                            yz = y*z
                            result = ysum+zz+xz+yz
                            if result > n:
                                break
                            if result == n:
                                count[n-1] += 1
                                #print("zpath")
                                used.append
    for x in range(N):
        print(count[x])