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:
def resolve():
    import sys
    import math

    readline = sys.stdin.readline

    N = int(readline())

    for i in range(1, N + 1):
        ans = 0
        li = int(math.sqrt(i))
        for x in range(1, li):
            xx = x * x
            for y in range(1, li):
                if x <= y:
                    break
                yy = y * y
                xy = x * y
                x_y = x + y
                value = (x_y) ** 2 - 4 * (xx + yy + xy - i)
                if value <= 0:
                    continue
                cal = math.sqrt(value)
                z1 = (-(x_y) + cal) / 2
                z2 = (-(x_y) - cal) / 2
                if (1
                        and 1 <= z1
                        and z1 % 1 == 0):
                    ans += 1
                if (1
                        and 1 <= z2
                        and z2 % 1 == 0):
                    ans += 1
        print(ans)


resolve()

Submission status: Wrong Answer

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


def g(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
Heihou_1 = np.array([(3*i)**2-(3*i) for i in range(1,40)])
#Heihou_3 = [i**2 for i in range(4,N+1) if i%3 != 0]
n_list = []
for i in range(1,50):
    for j in range(1,50):
        n_list.append(3*(i)**2 + 2*i*j + j**2)
n_list.sort()

#print(Heihou_1[-1])
#print(n_list)

for i in range(1,N+1):
    if np.any(Heihou_1 == i):
        print(1)
        Heihou_1 = Heihou_1[1:-1]
    elif i in n_list:
        print(3)
        n_list = n_list[1:-1]
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(1,46):
  for j in range(1,46):
    for k in range(1,46):
      A.append(i**2+j**2+k**2+i*j+i*k+j*k)
A = sorted(A)
B = [0]*10001
for i in range(10001):
  if A[i] < 10001:
    B[A[i]] += 1
C = B[1:N+1]
[print(i) for i in C]

Submission status: Wrong Answer

Solution code:
### Problem C
import math

N = int(input())

for x in range(1,N+1):
    cnt = 0
    if x < 5000:
        up = int(math.sqrt(x))+1
    else:
        up = int(math.sqrt(x))-50
    for i in range(1,up):
        for j in range(1,up-(i-1)):
            for k in range(1,up-(i-1)-(j-1)):
                if (i + j + k)**2 == x + (i*j + j*k + k*i):
                    cnt += 1
                    
    print(cnt)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
count=1
while count<=6:
    print(0)
    count+=1
    if count==6:
        print(1)
        count+=1

ans=n*[0]
root=4
found=False
while not found:
    thing=math.ceil(int(root/3))
    while thing>0:
        s=root-thing
        a=int(s/2)
        b=s-a
        firstindex=root**2-(thing*a+a*b+thing*b)
        if firstindex>n:
            found=True
            break
        while a>=1 and b>=1:
            ways=len(set([thing,a,b]))
            index=root**2-(thing*a+a*b+thing*b)
            if index<=n:
                if ways==1:
                    ans[index-1]=1    
                elif ways==2:
                    ans[index-1]=3
                else:
                    ans[index-1]=6
                if a<b:
                    a-=1
                    b+=1
                else:
                    a+=1
                    b-=1
        thing-=1
    root+=1

for i in range(n):
    print(ans[i])