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 for i in range(n)]


for i in range(101):
  for j in range(101):
    for k in range(101):
      a = i*i +j*j + k*k + i*j +j*k + k*i
      if a < n:
        ans[a]+=1
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0] * (n + 1)
loop = int((n/6) ** 1.5) + 1

def f(i, j, k):
    return i ** 2 + j ** 2 + k ** 2 + i*j + j*k + k*i

for i in range(1, loop+1):
    for j in range(1, loop+1):
        for k in range(1, loop+1):
            res = int(f(i, j, k))
            if res <= n:
                ans[res] += 1

for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
def f(n):
    counts = [0]*n
    x_max = int(np.sqrt(n))
    for x in range(1,x_max+1):
        y_max = int(np.sqrt(n-x**2))
        for y in range(1,y_max+1):
            z_max = int(np.sqrt(n-x**2-y**2))
            for z in range(1,z_max+1):
                if x**2+y**2+z**2+x*y+y*z+z*x < n:
                    counts[x**2+y**2+z**2+x*y+y*z+z*x-1] += 1
    return counts
 
N = int(input())
counts = f(N)
for i in range(N):
    print(counts[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
import math

for i in range(1,N+1):
    ans=0
    for x in range(1,33):
        x2=x*x
        for y in range(1,x+1):
            a=-(3*(x2)+3*(y*y)+2*x*y)/4+i
            if a>0:
                b=(math.sqrt(a)-(x+y)/2)
                if b>0 and b%1==0.0:
                    if x==y:
                        ans+=1
                    else:
                        ans+=2

    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


def function(N):
    for n in range(1, N+1):
        if n < 6:
            print(0)
        else:
            ans = 0
            number = int(np.sqrt(2*n))
            X = [int(i) for i in range(2, number+1)]
            for x in X:
                Y = [int(j) for j in range(x, number+1)]
                for y in Y:
                    Z = [int(k) for k in range(y, number+1)]
                    for z in Z:
                        if x**2+y**2+z**2 == 2*n:
                            if x+y > z+1 & (x+y+z) % 2 == 0:
                                if x == y & y == z:
                                    ans += 1
                                else:
                                    ans += 3

            print(ans)


if __name__ == '__main__':
    N = int(input())
    function(N)

Submission status: Wrong Answer

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

N = int(input())
f = [0] * N
for i in range(1, N+1):
  count = 0
  for x in range(1, int(math.sqrt(i)+1)):
    for y in range(x, int(math.sqrt(i)+1)):
      z = i-x-y
      if z < y:
        break
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if n <= N:
        if x == y and x == z:
          f[n-1] += 1
        elif x == y or y == z:
          f[n-1] += 3
        elif x != y and x != z and y != z:
          f[n-1] += 6
for i in f:
  print(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 = [0]*(n+1)
    for x in range(101):
        for y in range(101):
            for z in range(101):
                temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if temp <= n:
                    l[temp] += 1

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main_v2():
    N = int(input())
    f_lst = [0 for _ in range(N)]

    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                ans = x*x + y*y + z*z + x*y + y*z + z*x
                if ans < N:
                    f_lst[ans - 1] += 1

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


if __name__ == "__main__":
    main_v2()

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ans_list = [0 for i in range(N+1)]
cnt_list = [0 for i in range(N+1)]
for x in range(1,int(math.sqrt(N))+1):
    for y in range(1,x+1):
        for z in range(1,y+1):
            f = x**2 +y**2 +z**2 +x*y +y*z + z*x
            if(f<=N):
                if(x==y==z):
                    ans_list[f] += 1
                else:
                    cnt_list[f] += 1
for a in range(1,N+1):
    print(ans_list[a]+cnt_list[a]*3)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0]*(n+5)

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n>=temp:
                print(x,y,z, temp)
                ans[temp]+=1


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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

def calc(n):
    for i in range(1,int((n+1)**0.5)):
        for j in range(1,int((n+1)**0.5)):
            for k in range(1, int((n+1)**0.5)):
                if (i+j+k)**2 - i*j - j*k - k*i == n:
                    if i == j == k:
                        return 1
                    else:
                        return 3
    return 0    

def main():
    ans = 0
    n = int(input())
    for i in range(1,n):
        print(calc(i))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0] * n
loop = int((n/6) ** 1.5) + 1

def f(i, j, k):
    return i ** 2 + j ** 2 + k ** 2 + i*j + j*k + k*i

for i in range(1, loop+1):
    for j in range(1, loop+1):
        for k in range(1, loop+1):
            res = int(f(i, j, k))
            if res <= n:
                ans[res] += 1

for a in ans:
    print(a)

Submission status: Wrong Answer

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

for x in range(1, 1000):
    for y in range(1, 1000):
        for z in range(1, 1000):

            f = x**2 + y**2 + z**2 + x*y + y*z + z*x

            if f < 10000:
                ans[f-1] = ans[f-1] + 1 

            if f > N:
                break
            
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [0]*(N+1)
for x in range(101):
    for y in range(101):
        for z in range(101):
            d = x*x+y*y+z*z+x*y+y*z+x*z
            if d <= N:
                a[d] += 1
for i in range(1, N+1):
    print(a[i])

Submission status: Wrong Answer

Solution code:
N=int(input())

a=[0]*N

x=1
while x<N:
    y=1
    while x*x+y*y+x*y<N:
        z=1
        while z*z+x*x+y*y+x*y+z*y+z*x<N:
            a[z*z+x*x+y*y+x*y+z*y+z*x]+=1
            z+=1
        y+=1
    x+=1

for n in a:
    print(n)

Submission status: Wrong Answer

Solution code:
N = int(input())

def perfect_number(x, y, z):
  n = x**2 + y**2 + z**2 + x*y + y*z + z*x
  return n
l = []
for x in range(1, N):
  for y in range(1, N):
    for z in range(1, N):
      n = perfect_number(x,y,z)
      if n > N:
      	break
      else:
        l.append(n)


counts = [l.count(x) for x in sorted(set(l))]
d = dict(zip(l, counts))
for i in range(1, N+1):
  if i in d:
  	print(d[i])
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np


def function(N):
    for n in range(1, N+1):
        if n < 6:
            print(0)
        else:
            ans = 0
            number = int(np.sqrt(2*n))
            X = [int(i) for i in range(2, number+1)]
            for x in X:
                Y = [int(i) for i in range(x, number+1)]
                for y in Y:
                    Z = [int(i) for i in range(y, number+1)]
                    for z in Z:
                        if x**2+y**2+z**2 == 2*n:
                            if x+y > z+1 & (x+y+z) % 2 == 0:
                                if x == y & y == z:
                                    ans += 1
                                else:
                                    ans += 3

            print(ans)


if __name__ == '__main__':
    N = int(input())
    function(N)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans  = [0 for i in range(10**5)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0]*(n+5)

for x in range(1,10):
    for y in range(1,10):
        for z in range(1,10):
            temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n>=temp:
                print(x,y,z, temp)
                ans[temp]+=1


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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[0]*N
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            n=i*i+j*j+k*k+i*j+i*k+j*k
            if(n>N):
               continue
            a[n-1]+=1
for i in range(1,N):
    print(a[i])

Submission status: Wrong Answer

Solution code:
on = int(input())
res = 0
for n in range(1, on + 1):
    res = 0
    for x in range(1, 100 + 5):
        nn = n
        nn -= x * x
        if nn < 0:
            break
        for y in range(x, 100 + 5):
            nn -= y * y
            nn -= x * y
            if nn < 0:
                break
            for z in range(y, 100 + 5):
                if x * x + y * y + z * z + x * y + y * z + z * x == n:
                    dat = [x, y, z]
                    dat.sort()
                    a, b, c = dat
                    if a == b == c:
                        res += 1
                    elif a == b and b != c:
                        res += 3
                    elif c == b and a != b:
                        res += 3
                    elif a != b and b != c:
                        res += 6
                    # print(n, x, y, z)
                if nn < 0:
                    break

    print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans  = [0 for i in range(10**5)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0]*(10**4+1)
for x in range(10**2+1):
    for y in range(10**2+1):
        for z in range(10**2+1):
            i = x*x + y*y + z*z + x*y + x*z + y*z
            if i <= 10**4:
                ans[i] += 1
            else:
                break

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

Submission status: Wrong Answer

Solution code:
import math
n = int(input())

v = [0]*(100000)

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      v[x*x+y*y+z*z+x*y+y*z+z*x] += 1

print('\n'.join(map(str,v[1:])))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [0 for x in range(N)]
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            n = i*i+j*j+k*k+i*j+j*k+i*k
            if n <= N:
                a[n] += 1
for i in range(N):
    print(a[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [0 for x in range(N)]
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            n = i*i+j*j+k*k+i*j+j*k+i*k
            if n < N:
                a[n] += 1
for i in range(N):
    print(a[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, 33):
  for j in range(1, 33):
    for k in range(1, 33):
      d[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + i * k] += 1
for i in range(n):
  print(d[i + 1])

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0] * (n + 1)
for x in range(1, n):
    if x * x >= n:
        break
    for y in range(1, n):
        if x * x + y * y + x * y >= n:
            break
        for z in range(1, n):
            key = x * x + y * y + z * z + x * y + y * z + z * x
            if key > n:
                break
            ans[key] += 1
for i in range(n + 1):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=[0]*(N+5)
for i in range(100) :
    for j in range(100) :
        for k in range(100) :
            n=i*i+j*j+k*k+i*j+j*k+k*i
            if N>=n :
                ans[n]+=1

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

Submission status: Wrong Answer

Solution code:
n=int(input())
 
ans=[0]*(n+1)
 
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            f= x**2 + y**2 + z**2 + x*y + y*z + z*x
            if f==n:
                ans[f]+=1
 
for i in range(1,n+1):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    ans = [0 for _ in range(100001)]
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                tmp = x * x + y * y + z * z + x * y + y * z + z * x
                if tmp < 10000:
                    ans[tmp] += 1
    
    for i in range(1, N+1):
        print(ans[i])
    return

resolve()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
ans = np.zeros((10**4+5))
for i in range(1,51):
  for j in range(1,51):
    for l in range(1,51):
      f = (i+j)**2+(j+l)**2+(l+i)**2
      if((f%2==0) and (f<=2*10**4)):
        ans[int(f/2)] += 1

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a = [0]*(1000000)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            a[i**2+j**2+k**2+i*j+j*k+i*k]+=1
for i in range(n+1):
    print(a[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
import math

def f(n):
    k = 0
    for x in range(1,int(math.sqrt(n))+2):
        for y in range(1,int(math.sqrt(n))+2):
            for z in range(1,int(math.sqrt(n))+2):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    k += 1
    return k

for p in range(N):
    print(f(p))

Submission status: Wrong Answer

Solution code:
# 1 <= x,y,z
# x^2+y^2+z^2+xy+yz+zx = n
def calc(n):
    c = 0
    for x in range(1,32):
        for y in range(1,32):
            for z in range(1,32):
                if n == x**2+y**2+z**2+x*y+y*z+z*x:
                    c += 1
    print(c)
    
    
n = int(input())
for i in range(1,n+1):
    calc(i)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())

v = [0]*(100000)

for x in range(101):
  for y in range(101):
    for z in range(101):
      v[x*x+y*y+z*z+x*y+y*z+z*x] += 1

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

Submission status: Wrong Answer

Solution code:
# 1 <= x,y,z
# x^2+y^2+z^2+xy+yz+zx = n
def calc(n):
    c = 0
    for x in range(1,31):
        for y in range(1,31):
            for z in range(1,31):
                if n == x**2+y**2+z**2+x*y+y*z+z*x:
                    c += 1
    print(c)
    c = 0
    
    
n = int(input())
for i in range(1,n+1):
    calc(i)

Submission status: Wrong Answer

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

import sys
import math

def main():
    input = sys.stdin.readline
    N = int(input())

    result = 0
    ans_list = [0]*(N+1)
    root_n =int(math.sqrt(N))+1

    for i in range(1,root_n):
        for j in range(1,root_n):
            for k in range(1,root_n):
                f = i**2+j**2+k**2+i*j+i*k+j*k
                if f < N:
                    ans_list[f] += 1 
    
    for i in range(1,N+1):
        print(ans_list[i])
        
                        

    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

# def f2(x, y, z, n):
#     return x*x+y*y+z*z+x*y+y*z+z*x

def f(x, y, z, n):
    if x*x+y*y+z*z+x*y+y*z+z*x == n:
        return True
    else:
        return False
def main():
    N = int(input())
    for n in range(1, N + 1):
        cnt = 0
        for x in range(1, 100):
            if x * x > n:
                break
            for y in range(x, 100):
                if x*x + y*y > n:
                    break
                for z in range(y, 100):
                    if x*x + y*y + z*z > n:
                        break
                    if f(x, y, z, n):
                        # print(x, end=' ')
                        # print(y, end=' ')
                        # print(z)
                        if x == y == z:
                            cnt += 1
                        else:
                            cnt += 3
        # print(n, end=': ')
        print(cnt)
    return
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools
import math
import collections

def func(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
 
n = int(input())
s = int(math.sqrt(n))
nums = list(range(1,s))
arr = []
com = list(itertools.product(nums, repeat=3))
for i in range(len(com)):
    # print(com)
    ans = func(com[i][0],com[i][1],com[i][2])
    arr.append(ans)
 

c = collections.Counter(arr)
for i in range(n):
    print(c[i])

Submission status: Wrong Answer

Solution code:
# C - XYZ Triplets
N = int(input())
ans = 0
for l in range(N):
    ans = 0
    for i in range(100):
        for j in range(i,100-(i+1)**2):
            # a = (i+1)+(j+1)
            # b = (i+1)*(j+1)
            # if (i + 1) ** 2 + (j + 1) ** 2 + (k + 1) ** 2 + (i + 1) * (j + 1) + (j + 1) * (k + 1) + (k + 1) * (
            #         i + 1) == l + 1:
            for k in range(100-(i+1)**2-(j+1)**2):
                if (i + 1) ** 2 + (j + 1) ** 2 + (k + 1) ** 2 + (i + 1) * (j + 1) + (j + 1) * (k + 1) + (k + 1) * (
                        i + 1) == l + 1:
                    if i == j == k:
                        ans = 1
                        break

                    elif (i == j and j != k) or (k == j and i != k):
                        ans = 3
                        break
                    else:
                        ans = 6
                        break
                break
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [0] * (N + 5)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            tmp = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if N >= tmp:
                ans[tmp] += 1

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

Submission status: Wrong Answer

Solution code:
def ff(x,y,z):
    return(x**2+y**2+z**2+x*y+y*z+z*x)

n=int(input())

an=[ff(i,j,k) for i in range(1,23) for j in range(1,23) for k in range(1,23)]

for i in range(1,n+1):
    print(an.count(i))

Submission status: Wrong Answer

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())

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

def Main():
    n = I()
    c = [0]*n
    fa = True
    for i in range(1,n+1):
        if n<f(i,i,i):  break
        for j in range(1,n+1):
            if n<f(i,j,j):  break
            for k in range(1,n+1):
                tmp = f(i,j,k)
                if n<tmp:   break
                c[tmp-1] += 1

    for rep in c:
        print(rep)
    return

if __name__=='__main__':
    Main()

Submission status: Wrong Answer

Solution code:
import numpy as np


def function(N):
    for n in range(1, N+1):
        if n < 6:
            print(0)
        else:
            ans = 0
            number = int(np.sqrt(2*n))
            X = [int(i) for i in range(2, number+1)]
            for x in X:
                Y = [int(i) for i in range(x, number+1)]
                for y in Y:
                    Z = [int(i) for i in range(y, number+1)]
                    for z in Z:
                        if x**2+y**2+z**2 == 2*n:
                            if x+y > z+1 & y+z > x+1 & x+z > y+1:
                                if x == y & y == z:
                                    ans += 1
                                else:
                                    ans += 3

            print(ans)


if __name__ == '__main__':
    N = int(input())
    function(N)

Submission status: Wrong Answer

Solution code:
N=int(input())
ans = [0]*10000000
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            ans[i**2+j**2+k**2+i*j+j*k+i*k] += 1
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, ), cache=True)
def main(n):
    for s in range(1, n+1):
        ans = 0
        for i in range(1, 101):
            for j in range(1, 101):
                for k in range(1, 101):
                    if i*i + j*j + k*k + i*j + j*k + k*i == s:
                        ans += 1
    print(ans)
    ans = 0


n = int(read())
main(n)

Submission status: Wrong Answer

Solution code:
import numpy as np


def function(N):
    for n in range(1, N+1):
        print('number='+str(n))
        if n < 6:
            print(0)
        else:
            ans = 0
            number = int(np.sqrt(2*n))
            X = [int(i) for i in range(2, number+1)]
            for x in X:
                Y = [int(i) for i in range(x, number+1)]
                for y in Y:
                    Z = [int(i) for i in range(y, number+1)]
                    for z in Z:
                        if x**2+y**2+z**2 == 2*n:
                            if x+y > z+1 & y+z > x+1 & x+z > y+1:
                                if x == y & y == z:
                                    ans += 1
                                    print(x, y, z)
                                else:
                                    ans += 3
                                    print(x, y, z)

            print(ans)


if __name__ == '__main__':
    N = int(input())
    function(N)