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: Wrong Answer

Solution code:
import math
N = int(input())
for i in range(1,N+1):
    cnt=0
    t=math.sqrt(i)
    t=int(t)
    for x in range(1,t+1):
        for y in range(1,t+1):
            z=x
            if x*x+y*y+z*z+x*y+y*z+z*x==i:
                cnt+=1
            if x!=y:
                z=y
                if x*x+y*y+z*z+x*y+y*z+z*x==i:
                    cnt+=1 

    if cnt%2==0 and cnt!=0:
        print(cnt+1)
    else:
        print(cnt)

Submission status: Wrong Answer

Solution code:
t = int(input())

l = [0]*10000000
ans=0
x=1
y=1
z=1

for x in range(1,70):
    for y in range(1,70):
        for z in range(1,70):
            ans = x*x + y*y +z*z +x*y + y*z + z*x
            l[ans]+=1

# for i in range(1000):
#   ans = x*x + y*y +z*z +x*y + y*z + z*x
#   l[ans] = 1
   
#   z+=1
#   ans = x*x + y*y +z*z +x*y + y*z + z*x
#   l[ans] = 3
   
#   y+=1
#   ans = x*x + y*y +z*z +x*y + y*z + z*x
#   l[ans] = 3
   
#   x+=1
   
for i in range(1, t+1):
    print(l[i])

Submission status: Wrong Answer

Solution code:
def f(n):
    res = 0
    pairs = set()
    for x in range(1, 60):
        for y in range(x, 60):
            temp = - 3 * (x + y) ** 2 + 4 * n + 4 * x * y
            if (x + y) % 2:
                continue
            elif temp < 0:
                continue
            temp2 = int(temp ** .5)
            if temp2 * temp2 != temp:
                continue
            elif temp2 % 2:
                continue
            z1 = - (x + y) // 2 + temp2 // 2
            z2 = - (x + y) // 2 - temp2 // 2
            if z1 >= 1:
                key = tuple(sorted((x, y, z1)))
                if key in pairs:
                    continue
                if x == y == z1:
                    res += 1
                elif x != y != z1:
                    res += 6
                else:
                    res += 3
                pairs.add(key)
            if z2 >= 1:
                key = tuple(sorted((x, y, z2)))
                if key in pairs:
                    continue
                if x == y == z2:
                    res += 1
                elif x != y != z2:
                    res += 6
                else:
                    res += 3
                pairs.add(key)
    return res


N = int(input())
for i in range(1, N + 1):
    print(f(i))

Submission status: Wrong Answer

Solution code:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n = int(input())

    l = []
    print("aaa",math.floor(math.sqrt(n)))
    for i in range(1, math.floor(math.sqrt(n))):
        l.append(i)

    l_list = list(itertools.combinations_with_replacement(l, 3))

    ans_list = []
    for j in range(len(l_list)):
        x = l_list[j][0]
        y = l_list[j][1]
        z = l_list[j][2]
        ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
        ans_list.append((ans, [x, y, z]))

    for i in range(1, n+1):
        count = 0
        for j in range(len(ans_list)):
            if ans_list[j][0] == i and ans_list[j][1][0] == ans_list[j][1][1]and ans_list[j][1][2] == ans_list[j][1][1]:
                count += 1
            elif ans_list[j][0] == i:
                count += 3
            if ans_list[j][0] > i:
                break

        print(count)


if __name__ == '__main__':
    main()