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:
n = int(input())
ans = 0
f = [0]*15000
for x in range(1,50):
    for y in range(1,50):
        for z in range(1,50):
            f[x**2+y**2+z**2+x*y+y*z+z*x]+=1
            z+=1
        y+=1
    x+=1
for i in range(1,n+1):
    print(f[i])

Submission status: Wrong Answer

Solution code:
n=int(input())

for i in range(1,n+1):
  count = 0
  for x in range(1,101):
    for y in range(x,101):
      if (x+y)**2 > 2*i:
        break
      for z in range(y,101):
        fn = (x+y)**2 + (y+z)**2 + (z+x)**2
        if fn > 2*i:
          break
        if fn == 2*i:
          if x != y and y != z and z != x:
            count = 6
          elif z == y and y == z and z == x:
            count = 1
          else:
            count = 3
          
  print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())

l = [0 for _ in range(N)]
for x in range(1, 10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            m = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if m <= N:
                if x == y == z:
                    l[m - 1] += 1
                elif x == y or y == z or z == x:
                    l[m - 1] += 3
                else:
                    l[m - 1] += 6
            else:
                break

for i in range(N):
    print(l[i])

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement
N = int(input())

def calc(x: int, y: int, z: int) -> int:
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

memo = {}
for x,y,z in combinations_with_replacement(range(1, 43), 3):
    l = len(set([x,y,z]))
    num = calc(x,y,z)
    if l == 1:
        memo[num] = 1
    elif l == 2:
        memo[num] = 3
    else:
        memo[num] = 6

for i in range(1, N+1):
    print(memo.get(i, 0))

Submission status: Wrong Answer

Solution code:
N = int(input())
Xlist = [0]*(10**4)
for i in range(100):
    for j in range (60):
        for k in range(60):
            A = (i + j + 2)**2 + (k + j + 2)**2 + (i + k + 2)**2
            if ((A % 2) == 0)and(A <= 20000):
                Xlist[(A//2 -1)] += 1

for a in range (N):
    print(Xlist[a])

Submission status: Wrong Answer

Solution code:
N = int(input())
for i in range(1, N + 1):
    x = 0
    for j in range(1, 21):
        for k in range(1, 21):
            for l in range(1, 21):
                if i == j ** 2 + k ** 2 + l ** 2 + j * k + k * l + l * j:
                    x += 1
    print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
import math
for a in range(1, N+1):
    n = 0
    top = int(math.sqrt(a)/1.5)
    for b in range(1, top):
        for c in range(1, b+1):
            for d in range(1, c+1):
                if (b**2) + (c**2) + (d**2) + (b*c) + (c*d) + (d*b) == a:
                    n += 1
    print(n)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N=int(input())
ans=[0]*(10**7)
for x in range(1,N+1):
    if x**2>N:
        break
    for y in range(x,N+1):
        if x**2+y**2>N:
            break
        for z in range(y,N+1):
            if x**2+y**2+z**2>N:
                break
            else:
                kari=[x,y,z]
                #print(kari)
                if x**2+y**2+z**2+x*y+y*z+z*x<=len(ans):
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=len(list(combinations(kari,2)))
if N>=6:
    ans[5]=1
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [0] * N

for x in range(1, 101):
    for y in range(x, 101):
        for z in range(y, 101):
            calc = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if calc > N:
                break
            L[calc-1] += 3
            if x == y == z:
                L[calc-1] -= 2

for l in L:
    print(l)

Submission status: Wrong Answer

Solution code:
import math


def pattern(x, y, z):
    if x == y == z:
        return 1
    elif x != y != z:
        return 6
    else:
        return 3


def check(upper_value, ans):
    cnt = 0
    for x in range(1, upper_value):
        for y in range(x, upper_value):
            for z in range(y, upper_value):
                if x*(x+y+z) + y*(y+z) + z*z == ans:
                    cnt += pattern(x, y, z)
    print(cnt)


N = int(input())
# x^2 + y^2 + z^2 + x*y + y*z + z*x = n

for i in range(N+1):
    upper_value = int(math.sqrt(i))
    if upper_value < 2:
        print(0)
    else:
        check(upper_value, i)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

def count_xyz(n):
    counts = np.zeros(n + 1, dtype=int)
    for x in range(1, math.ceil(math.sqrt(n)) + 1):
        if func(x, x, x) > n:
                break
        for y in range(x, math.ceil(math.sqrt(n)) + 1):
            if func(x, y, y) > n:
                    break
            for z in range(y, math.ceil(math.sqrt(n)) + 1):
                if func(x, y, z) > n:
                    break
                if len({x, y, z}) == 1:
                    counts[func(x, y ,z)] += 1
                elif  len({x, y, z}) == 2:
                    counts[func(x, y ,z)] += 3
                else:
                    counts[func(x, y ,z)] += 6
    
    return counts


def main():
    N = int(input())
    counts = count_xyz(N)
    for i in range(1, N):
        print(counts[i])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
def f(i):
  co=0
  for z in range(1,7):
    for y in range(1,7):
      for x in range(1,7):
        if x**2+y**2+z**2+z*y+z*x+y*x==i:
          co+=1
  return co
for i in range(1,n+1):
  co=f(i)
  print(co)

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)/2)
        for i in range(1,up):
            for j in range(1,up):
                for k in range(1,up):
                    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())
nlist = [0]*n
for x in range(1,math.ceil(math.sqrt(n-1)-1)):
    for y in range(1,math.ceil(math.sqrt(n-1)-1)):
        for z in range(math.ceil(math.sqrt(n-1)-1)):
            temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if temp > n:
                break
            else:
                nlist[temp-1] +=1

for num in nlist:
    print(num)

Submission status: Wrong Answer

Solution code:
import sys
import math
import statistics
import itertools
from collections import deque
n=int(input())
#n,m=map(int,input().split()))
#lis=list(map(int,input().split()))
#side=[]
#for _ in range(m):
    #side.append(tuple(map(int,input().split())))
ans_lis =[0]*1000000

#per_lis=itertools.permutations(list(range(1,4)))

for i in range(1,11):
    for j in range(1,11):
        for k in range(1,11):
            tmp=i**2+j**2+k**2+i*j+j*k+k*i
            ans_lis[tmp-1]+=1
for i in range(n):
    print(ans_lis[i])

Submission status: Wrong Answer

Solution code:
def solve():
    for n in range(1,N+1):
        cnt = 0
        flag = False
        for x in range(1,int(n**0.5)):
            if 6*(n**2) == n:
                cnt += 1
                print(n,cnt)
                break
            for y in range(1,x+1):
                if 3*x**2 + y**2 + 2*x*y == n:
                    cnt += 3
#                    print(n,cnt)
                    flag = True
                    break
                for z in range(1,x+1):
                    if x**2+y**2+z**2+x*y+y*z+z*x==n:
                        cnt += 3
                        x += 1
                        flag = True
                        break
                if flag:
                    break
            if flag:
                break
        print(n,cnt)

if __name__=="__main__":
    N = int(input())
    solve()

Submission status: Wrong Answer

Solution code:
from itertools import combinations, combinations_with_replacement
from math import sqrt


n = int(input())
ans = [0] * (n + 1)
for x, y, z in combinations_with_replacement(range(1, 110), 3):
    i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if i <= n:
        if x == y == z:
            ans[i] += 1
        elif all([not(s != t) for s, t in combinations([x, y, z], 2)]):
            ans[i] += 6
        else:
            ans[i] += 3

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
for i in range(1, N+1):
    ans = 0
    for x in range(1, round(math.pow(i, 1/3))):
        for y in range(1, round(math.pow(i, 1/3))):
            for z in range(1, round(math.pow(i, 1/3))):
                tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if tmp == i:
                    ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
for l in range(n):
    c=0
    for i in range(n):
        for j in range(n):
            for k in range(n):
                if i>=1 and j>=1 and k>=1:
                    m = i*i+j*j+k*k+i*j+j*k+k*i
                    if m == l:
                        c += 1
    print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(1, n + 1):
    cnt = 0
    perf = False
    one = False
    diff = False
    for x in range(1, 41):
        for y in range(x, 41):
            for z in range(y, 41):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
                    cnt += 1
                    if (x == y and y != z) or (x == z and x != y) or (y == z and x != y):
                        print(cnt * 3)
                        break
                    elif x != y and y != z and z != x:
                        print(cnt * 6)
                        break
                    else:
                        print(cnt)
                        break
    if cnt == 0:
        print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
L=[0]*N
for x in range(1,int(N**0.5)):
    for y in range(1,int(N**0.5)):
        for z in range(1,int(N**0.5)):
            f=x**2+y**2+z**2+x*y+y*z+z*x
            if f<=N:
                if x==y and x==z:
                    L[f-1]=1
                else:
                    L[f-1]=3
for i in range(N):
    print(L[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [0] * 25000
for x in range(1, 50):
    for y in range(1, 50):
        for z in range(1, 50):
            n_ = x**2 + y**2 + z**2 + x*y + y*z + z*x
            
            l = len({x, y, z})
            if l == 1:
                tmp = 1
            elif l == 2:
                tmp = 3
            else:
                tmp = 6
            arr[n_-1] += tmp

# print(*arr[:n], sep='\n')
for num, res in enumerate(arr[:n]):
    print(num+1, res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

n = int(input())

for i in range(n + 1):
    s = 0
    p = math.floor(n / 6) + 1
    if i > 5:
        for x in range(1, p + 1):
            for y in range(x, p + 1):
                for z in range(y, p + 1):
                    if (x**2) + (y**2) + (z**2) + (x*y) + (y*z) + (z*x) == i:
                        if x == y and y == z:
                            s += 1
                        else:
                            s += 3
    print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
def ff(x,y,z):
    n = x**2+y**2+z**2+x*y+y*z+z*x
    return n
maxx=30

c=[]
ans = [0]*N
for i in range(1,maxx+1):
    for j in range(1,maxx+1):
        for k in range(1,maxx+1):
            r=ff(i,j,k)
            c.append(r)
cc = [i for i in c if i<=N]

for i in cc:
    ans[i-1] += 1

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = 10**4
tmp = [0]*((10**4)+1)
for x in range(1,int(-(-n**0.5//1))+1):
    for y in range(1,x+1):
        for z in range(1, y+1):
            if x*x + y*y + z*z + x*y + y*z + z*x < 10**4:
                if x == y and y == z and z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x] +=1
                elif x == y or y == z or z == x:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 3
                else:
                    tmp[x*x + y*y + z*z + x*y + y*z + z*x]  += 6
for i in range(1, N+1):
    print(tmp[i])

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
# ans = [0 for _ in range(n)]
ans = [0] * n

for x in range(1, int(math.sqrt(n+1))):
    x2 = x*x
    for y in range(1, int(math.sqrt(n+1))):
        y2 = y*y
        xy = x * y
        tmp = x2 + y2 + xy
        if tmp >= n:
            break
        for z in range(1, int(math.sqrt(n+1))):
            tmp2 = tmp + z*z + y*z + z*x
            if tmp2 > n:
                break
            try:
                ans[tmp2 - 1] += 1
                print(x, y, z)
            except:
                pass
for i in range(n):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
n=int(input())
def f(i):
  co=0
  for z in range(1,5):
    for y in range(1,5):
      for x in range(1,5):
        if x**2+y**2+z**2+z*y+z*x+y*x==i:
          co+=1
  return co
for i in range(1,n+1):
  co=f(i)
  print(co)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
def g(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x
ans = []
def f(n):
    sum = 0
    rn = int(math.sqrt(n))
    
    for i in range(1,rn):
        print(i,end='')
        for j in range(1,rn):
            for k in range(1,rn):
                #print(i,j,k)
                if g(i,j,k) == n:
                    if (i == j and j==k):
                        sum += 1
                        ans.append(str(sum))
                        return
                    elif (i == j and j != k) or (i == k and j != k) or (i != j and j == k):
                        sum += 3
                        ans.append(str(sum))
                        return
                    elif i != j and i != k and j != k:
                        sum += 6
                        ans.append(str(sum))
                        return
                elif g(i,j,k) > n:
                    ans.append(str(0))
                    return
    ans.append(str(0))
                

    

for i in range(n+1):
    f(i)

print('\n'.join(ans))

Submission status: Wrong Answer

Solution code:
from numba import njit

@njit('i8(i8)', cache=True)
def fun(n):
    mx = int((n**.5) // 3) + 1
    pairs = 0
    for x in range(1, mx + 1):
        for y in range(x, mx + 1):
            for z in range(y, mx + 1):
                v = x*x + y*y + z*z + x*y + y*z + z*x
                if v == n:
                    if x == y == z:
                        pairs += 1
                    elif x == y or y == z:
                        pairs += 3
                    else:
                        pairs += 6
    return pairs

n = int(input())
for i in range(n):
    ps = fun(i + 1)
    print(ps)

Submission status: Wrong Answer

Solution code:
import math

if __name__ == '__main__':
    n = int(input().strip())


    def f(x, y, z):
        return int(x * x + y * y + z * z + x * y + y * z + z * x)

    for i in range(1, n + 1):
        count = 0
        if not i < 6:
            limit = int(math.sqrt(i))
            for x in range(1, limit + 1):
                if i == f(x, x, x):
                    count += 1
            tmp_count = 0
            for x in range(1, limit+1):
                for z in range(1, limit+1):
                    if not x == z and i == f(x, x, z):
                        tmp_count += 1
            count += tmp_count * 3

            tmp_count = 0
            for x in range(1, limit+1):
                for y in range(1, x):
                    for z in range(1, z):
                        if i == f(x, y, z):
                            tmp_count += 1
            count += tmp_count * 6

        print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
Xlist = [0]*(10**4)
for i in range(75):
    for j in range (70):
        for k in range(70):
            A = (i + j + 2)**2 + (k + j + 2)**2 + (i + k + 2)**2
            if ((A % 2) == 0)and(A <= 20000):
                Xlist[(A//2 -1)] += 1

for a in range (N):
    print(Xlist[a])

Submission status: Wrong Answer

Solution code:
# n = x^2 + y^2 + z^2 + xy + yz +zx = ((x+y)^2 + (y+z)^2 + (x+z)^2)/2
# 1 <= x, y, z
# n >= 6

import math

N = int(input())
ans = [0] * N

#lim = int(math.sqrt(N/2))
lim = int(math.sqrt(N))
for x in range(1, lim):
    for y in range(1, lim):
        for z in range(1, lim):
            #calc = ((x+y)**2 + (y+z)**2 + (x+z)**2) /2
            calc = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if calc <= N:
                ans[calc -1] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

list=[0]*N
for x in range(1,N+1):
    if x * x+2*x+3 > N:
        break
    for y in range(1,N+1):
        if x * x + y * y + x * y+x+y+1 > N:
            break
        for z in range(1, N + 1):
            val=x * x + y * y + z * z + x * y + y * z + z * x
            if val >= N:
                break
            list[val - 1] += 1
for i in range(N):
    print("{}".format(list[i]))