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())
A = [0]*(N+1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            i = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if i < N:
                A[i] += 1
for i in range(1, N+1):
    print(A[i])

Submission status: Wrong Answer

Solution code:
import time
import itertools


N = int(input())
def function(x,y,z):
    return pow(x,2) + pow(y,2) + pow(z,2) + (x * y) + (x * z ) + (y * z)

count = 0
start = time.time()

p = list(itertools.product(range(1,10),repeat=3))
a = []

for p_in in p:
    a.append(function(p_in[0],p_in[1],p_in[2]))

for n in range(1,N + 1):
    print(a.count(n))

elapsed_time = time.time() - start
# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")

Submission status: Wrong Answer

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

lst = [0]*75000
l = 0
res = 0

for i in range(1,42):
    for j in range(1,42):
        for k in range(1,42):
            lst[l] = i**2 + j**2 + k**2 + i*j + j*k + k*i
            l += 1

L = collections.Counter(lst)

for h in range(1,N+1):
    print(L[h])

Submission status: Wrong Answer

Solution code:
n = int(input())

for i in range(n):
    count = 0
    for x in range(1,i):
        if x ** 2 + x > i:
            continue
        for y in range(1, i):
            if x ** 2 + x * y + y ** 2 > i:
                continue
            for z in range(1,n - x ** 2 - y ** 2 - x * y):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > i:
                    break
                elif x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
                    count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

n=int(input())
lista= list(range(1,n+1,1))
list = list(map(int, lista))


for i in range(n):
  ans=0

  for a in list:
    if a**2 >= i:continue
    else:
    
      for b in list:
        if b**2 >= i:continue
        else:
        
          for c in list:
            if c**2 >= i:continue
            else:
            
              if a**2 + b**2 + c**2 + a*b + b*c + c*a == i:ans+=1

  print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
d=dict({i:0 for i in range(1,n+1)})
for s in range(3,201):
    for x in range(1,s+1-2):
        for y in range(1,s+1-x-1):
            z=s-x-y
            if x<y or y<z:
                continue
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if not v in d:
                continue
            if x==y==z:
                d[v]+=1
            else:
                d[v]+=3
for k in d.keys():
    print(d[k])

Submission status: Wrong Answer

Solution code:
n=int(input())
for i in range(1,n+1):
  count=0
  n=[1,1,1]
  num=6
  mark=0
  while num <= i:
    if num == i:
      count += 1
    n[mark]+=1
    num=n[0]*n[0]+n[1]*n[1]+n[2]*n[2]+n[0]*n[1]+n[1]*n[2]+n[2]*n[0]
    if mark==0:
      mark=1
    elif mark==1:
      mark=2
    elif mark==2:
      mark=0
  print(count)

Submission status: Wrong Answer

Solution code:
from itertools import permutations
N=int(input())
ans=[0]*(10**6)
for x in range(1,N+1):
    if x**2>N:
        break
    for y in range(1,N+1):
        if x**2+y**2>N:
            break
        for z in range(1,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<=10**5:
                    if len(set(kari))==1:
                        ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=1
                    elif len(set(kari))==2:
                        ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=3
                    else:
                        ans[x**2+y**2+z**2+x*y+y*z+z*x-1]=6
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
def f(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x
def calc(n):
    result_dict = {}
    for x in range(1,n):
        if n < f(x, 1, 1):
            return result_dict
        for y in range(1,n):
            if x < y:
                break
            for z in range(1, n):
                if y < z:
                    break
                if n < f(x, y, z):
                    break
                result_dict[f(x,y,z)] = (x, y, z)
    return result_dict

def output_result(result):
    if result:
        length = len(set(result))
        if length == 3:
            print(6)
        elif length == 2:
            print(3)
        elif length == 1:
            print(1)
        else:
            print(0)
    else:
        print(0)

n = int(input())
result_dict = calc(n)
for i in range(1, n):
    output_result(result_dict.get(i, False))
    # print(f"{i}: {result_dict.get(i, 0)}")

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []

for i in range(1, n + 1):
  cnt = 0
  for x in range(1, 50):
    for y in range(x, 50):
      for z in range(y, 50):
        if (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2 == i * 2:
          if (x == y and y != z) or (x != y and y == z) or (z == x and z != y):
            cnt += 3
          elif x == y == z:
            cnt += 1
          else:
            cnt += 6
  ans.append(cnt)
for j in range(n):
  print(ans[j])

Submission status: Wrong Answer

Solution code:
import math

def main():
    N = int(input())
    ans = [0]*(N+1)

    end = math.ceil(math.sqrt(N))

    for i in range(3,end+1):
        sn = i
        x = 1
        y = 1
        z = sn - 2
        ans[cal(x,y,z)] += func(i,x,y,z)
        while z >= math.ceil(sn / 2):
            y += 1
            z -= 1
            if x > z or y > z:
                break
            ans[cal(x,y,z)] += func(i,x,y,z)
            for j in range(y):
                x += 1
                z -= 1
                if x > z or y > z:
                    break
                ans[cal(x,y,z)] += func(i,x,y,z)
    
    for i in range(1,N+1):
        print(ans[i])
        

def func(n,x,y,z):
    if x == y and y == z and z == x:
        return 1
    else:
        return 3

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

main()

Submission status: Wrong Answer

Solution code:
N=int(input())
for i in range(5):
    print(0)
for n in range(6,N+1):
    ans = 0
    for i in range(1,int(n**0.5)):
        for j in range(i,int((-1-i+(-3*(i**2)+(6*i)-3+(4*n))**0.5)*0.5)):
            for k in range(j,int((-i-j+(-3*i**2-3*j**2-2*i*j+4*n))*0.5)):
                if i**2+j**2+k**2+i*j+j*k+k*i==n:
                    if i == j and j == k:
                        ans += 1
                    else:
                        ans += 3
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
L=[0]*N
for x in range(1,100):
    for y in range(x,101):
        for z in range(y,101):
            f=x**2+y**2+z**2+x*y+y*z+z*x
            if f<=N:
                if x==y==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())
N = 10 ** 4

l = [0 for _ in range(N + 1)]

for i in range(1, 42):
    for j in range(i, 42):
        for k in range(j, 42):
            s = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if s > N:
                continue
            d = len(set([i, j, k]))
            if d == 3:
                l[s] += 6
            elif d == 2:
                l[s] += 3
            elif d == 1:
                l[s] += 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
cs = [0]*N
for i in range(1,130):
    for j in range(1,130):
        for k in range(1,130):
            temp = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if temp < N and temp > 0:
                cs[temp-1] += 1
for i in range(N):
    print(cs[i])

Submission status: Wrong Answer

Solution code:
from sys import stdin
from sys import maxsize


def two_div(l):
    divs = []
    if l == 2:
        return [(1,1)]
    if l == 3:
        return [(2,1)]
    for m in range(l-1,l//2 -1,-1):
        divs.append((m,l-m))
    return divs


def three_div(mmm):
    divs = []
    rest = 1
    for m in range(mmm-2,mmm//2 -1,-1):
        rest += 1
        two_c = two_div(rest)
        for t in two_c:
            c = (m,t[0],t[1])
            divs.append(c)
    return divs

def triple(x,y,z):
    v = x*x + y*y + z*z + x*y + y*z + z*x
    return v

def main():
    n = int(input())
    ans = [0] * (n+1)
    for goukei in range(3,100):
        mini = maxsize
        factors = three_div(goukei)
        for x,y,z in factors:
            v = triple(x,y,z)
            
            if x == y and y == z and v <= n:
                ans[v] += 1
            elif v <= n:
                ans[v] += 3

            if mini > v:
                mini = v
        if mini >= n:
            break

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
        
    import math

    N = int(input())

    for n in range(1, N + 1):
        max_itr = min(60, int(math.sqrt(n)) + 1)
        
        ans_list = []
        ans = 0
        
        for x in range(1, max_itr):
            for y in range(1, x+1):
            # for y in range(1, max_itr):

                for z in range(1, x+1):
                # for z in range(1, max_itr):

                    left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                    if (left_eq == n):
                        tmp = [x, y, z]
                        tmp.sort()

                        if (tmp not in ans_list):
                            ans_len = len(set(tmp))
                            ans_list.append(tmp)

                        
                        


                        # ans += 1
                        
                            if (ans_len==3):
                                ans += 6
                            elif (ans_len == 2):
                                ans += 3
                            else:
                                ans += 1

        
        
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    N = int(input())
    ans = [0]*(N+1)

    end = math.ceil(math.sqrt(N))

    for i in range(3,end+1):
        sn = i
        x = 1
        y = 1
        z = sn - 2
        ans[cal(x,y,z)] += func(i,x,y,z)
        while z >= math.ceil(sn / 2):
            y += 1
            z -= 1
            print(x,y,z)
            if x > z or y > z:
                break
            ans[cal(x,y,z)] += func(i,x,y,z)
            for j in range(y):
                x += 1
                z -= 1
                if x > z or y > z:
                    break
                print(x,y,z)
                ans[cal(x,y,z)] += func(i,x,y,z)
    
    for i in range(1,N+1):
        print(ans[i])
        

def func(n,x,y,z):
    if x == y and y == z and z == x:
        return 1
    else:
        return 3

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

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
t = [0]*10001
for i in range(1,41):
    t[6*i**2] += 1
for i in range(1,58):
    for j in range(1,58):
        if(i != j):
            a = (i+j)**2 + 2*j**2
            if(a <= 10000):
                t[a] += 3
            else:
                break
for i in range(3,99):
    for j in range(2,i):
        for k in range(1,j):
            a = ((i+j)**2 + (j+k)**2 + (k+i)**2)//2
            if(a < 10000):
                t[a] += 6
            else:
                break
for i in range(1,n+1):
    print(t[i])

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

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

N = int(input())
f_list = np.zeros((N,1), dtype=int)

for x in range(1,math.floor((N//6)**0.5)+10):
  for z in range(1,math.floor(N**0.5)+10):
# for x in range(1,math.floor((N//6)**0.5)+1):
#   for z in range(1,math.floor(N**0.5)+1):
    for y in range(x,z+1):
      if f(x,y,z)<=N:
        if((x-y)*(y-z)*(z-x)==0): # 少なくとも2つが等しい
          if(x==y and y==z):
            f_list[f(x,y,z)-1] = 1
          else:
            f_list[f(x,y,z)-1] = 3
        else:
          f_list[f(x,y,z)-1] = 6

for i in range(N):
  print(f_list[i][0])