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())
lst=[0]*10020
for i in range(1, 41):
  for j in range(1, i+1):
    for k in range(1, j+1):
      temp=i**2+j**2+k**2+i*j+j*k+k*i
      if i==j and j==k:
        lst[temp]+=1
      elif i==j and j!=k:
         lst[temp]+=3
      elif j==k and k!=i:
         lst[temp]+=3
      elif k==i and i!=j:
         lst[temp]+=3
      elif i!=j and j!=k:
         lst[temp]+=6
for p in range(1, n+10):
  print(lst[p])

Submission status: Wrong Answer

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

for n in range(1, N+1):
    count = 0
    for z in range(1, int(sqrt(n))):
        for y in range(1,z+1):
            for x in range(1, y+1):
                if (y-x)**2 + (z-y)**2 + (z-x)**2 == n*2:
                    if len(set([x, y, z])) == 3:
                        count += 6
                    elif len(set([x, y, z])) == 2:
                        count += 3
                    elif len(set([x, y, z])) == 1:
                        count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
# 幅優先探索（行きがけ）
import collections
import sys
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    if N <= 5:
        for i in range(N):
            print(0)
        return

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

    for i in range(5):
        print(0)

    for i in range(6, N+1):
        cn = 0
        n = math.floor(math.sqrt(i)+1)
        start = math.floor(math.sqrt(i/6)+1)
        for j in range(start, n):
            if j**2 >= i-4:
                break
            for k in range(start, j+1):
                if j**2+k**2+j*k >= i-2:
                    break
                for l in range(start, k+1):
                    y = yy(j, k, l)
                    if y > i:
                        break
                    if y == i:
                        if j == k == l:
                            cn += 1
                        elif j != k != l:
                            cn += 6
                        else:
                            cn += 3
        print(cn)


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, 31):
        for y in range(1, 31):
            for z in range(1, 31):
                
                if i == ((x+y+z)**2 - z*(x+y) - (x*y)):
                    cnt += 1

    print(cnt)

Submission status: Wrong Answer

Solution code:

import itertools

N = int(input())

ans = [0]*N

x = []


i=1
while 1:
    if (i+1)*(i+1)+2>=N:
        break
    i+=1

for inputI in range(i):
    x.append(inputI+1)


S = list(itertools.combinations_with_replacement(x, 3))


for s in S:
    sum = (s[0]+s[1])*(s[0]+s[2])+pow(s[1],2)+pow(s[2],2)

    if sum <= N:
        if s.count(s[0])==3:
            ans[sum-1]=1
        elif s.count(s[0])==2 or s.count(s[1])==2:
            ans[sum-1]=3
        else:
            ans[sum-1]=6


for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())

count_n = []
ans = []
for o in range(n):
  temp = 0
  for i in range(1,50):
    for j in range(1,50):
      for k in range(1,50):
        if o ==  i ** 2 + j **2 + k ** 2 + i * j + j * k + k * i:
          count_n.append(o)

for i in range(1,n+1):
  if i not in count_n:
    ans.append(0)
  else:
    ans.append(count_n.count(i))
  
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

x, y, z = 1,1,1
ans_dict = {}

for x in range(1,100):
    for y in range(1,100-x):
        for z in range(1,100-x-y):
            ans = (x + y)**2 + (y + z)**2 + (z + x)**2
            if ans in ans_dict:
                ans_dict[ans] += 1
            else:
                ans_dict[ans] = 1

for n in range(1, N+1):
    if 2*n in ans_dict:
        print(ans_dict[2*n])
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
# cook your dish here
n = int(input())
import math 

def permute(i,j,k):
  if i == j and j == k:
    return 1
  elif i == j and j != k:
    return 3
  elif i != j and j == k:
    return 3
  else:
    return 6

def sumtn(i,j,k):
  return i*i + j*j + k*k + i*j + j*k + k*i
  
def getTriplets(n):
  i, j = 1, 1
  k = int(math.sqrt(n)) + 1
  ans = 0
  while i <= k:
    if sumtn(i,j,k) > n:
      # decrease j
      k -= 1
    elif sumtn(i,j,k) < n:
      # increase i reset j if j is at end else j += 1
      if j == k:      
        i += 1
        j = i
      else:
        j += 1
    else: # if equal increase j
      ans += permute(i,j,k)
    #   print(":::",i,j,k,":::", end = " ")
      k -= 1
  return ans     

for i in range(1,n+1):
#   print(i,end = " ")
  print(getTriplets(i))

Submission status: Wrong Answer

Solution code:
# vim: fileencoding=utf-8


def main():
    N = int(input())
    for n in range(1, N + 1):
        ans = 0
        if n <= 5:
            print(ans)
            continue

        end = False
        zMax = int((N + 1) / 6) + 1
        for x in range(1, int((N + 1) / 6) + 1):
            if end:
                break
            tx = x ** 2
            if tx + x >= n or x >= zMax:
                break
            for y in range(x, int((N + 1) / 6) + 1):
                if end:
                    break
                ty = tx + y ** 2 + x * y
                if ty + y + x >= n or y >= zMax:
                    break
                for z in range(y, int((N + 1) / 6) + 1):
                    t = ty + z ** 2 + y * z + z * x
                    if t == n:
                        if x == y and x == z:
                            ans += 1
                            end = False
                        if x == y or y == z:
                            ans += 3
                        else:
                            ans += 6
                        if z <= zMax:
                            zMax = z
                        break
                    if t >= n:
                        break
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[0]*10010
for i in range(1, 41):
  for j in range(1, i+1):
    for k in range(1, j+1):
      temp=i**2+j**2+k**2+i*j+j*k+k*i
      if i==j and j==k:
        lst[temp]+=1
      elif i==j and j!=k:
         lst[temp]+=3
      elif j==k and k!=i:
         lst[temp]+=3
      elif k==i and i!=j:
         lst[temp]+=3
      elif i!=j and j!=k:
         lst[temp]+=6
for p in range(1, n+1):
  print(lst[p])

Submission status: Wrong Answer

Solution code:
N = int(input())

numbers = []
for i in range(1, 42):
    numbers.append(i)

result = []
for i in range(len(numbers)):
  for j in range(i, len(numbers)):
    for k in range(j, len(numbers)):
      result.append([numbers[i], numbers[j], numbers[k]])

ns = {}
for i in range(10000):
    ns[i+1] = 0

for i in result:
    count = 3
    for j in range(3):
        if i[0] == i[1]:
            count -= 1
        if i[0] == i[2]:
            count -= 1
        if i[1] == i[2]:
            count -= 1
    junretsu = 0
    if count == 3:
        junretsu = 6
    elif count == 2:
        junretsu = 3
    else:
        junretsu = 1

    ns[i[0]**2 + i[1]**2 + i[2]**2 + i[0]*i[1] + i[1]*i[2] + i[2]*i[0]] = junretsu

for i in range(N):
    print(ns.get(i+1))

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, int(math.sqrt(n)) + 1):
            for y in range(x, int(math.sqrt(n)) + 1):
                if x*x + y*y > n:
                    break
                # a = f2(x, y, z)
                for z in range(y, int(math.sqrt(n)) + 1):
                    
                    if x*x + y*y + z*z > n:
                        break                    
                    if f(x, y, z, n):
                        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 math
N=int(input())
ans=[0]*(N+1)
tempn=0
xmax=int(math.sqrt(N))+2
for x in range(1,xmax+2):
    ymax=xmax-x
    for y in range(1,ymax+1):    
        zmax=ymax-y
        for z in range(1,zmax+1):
            tempn=((x+y+z)**2-(x*y+y*z+z*x))
            if tempn <= N:
                ans[tempn]+=1
for i in range(1,(N+1)):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import math
N = int(input()) + 1
#Nroot = int(math.sqrt(N/3))+1
for n in range(1,N):
    count = 0
    if n >= 6:
#        print(Nroot, int(math.pow(n,1/3))-1)
        for x in range(int(math.sqrt(n/3))+1, int(math.sqrt(n/3))-1 , -1):
            for y in range(x,0,-1):
                if (x+2*y)**2 > n:
                    for z in range(1,y+1):
    #                    print((x + y + z)**2 - (x*y + y*z + z*x), n,x,y,z)
    #                    print(x,y,z)
                        formula = (x + y + z)**2 - (x*y + y*z + z*x)
                        if formula == n:
                            if x == y and y == z:
                                count += 1
                            else:
                                count += 3
                            break

        print(count)
    else:
        print("0")

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
ans_d = {i: 0 for i in range(1,60000)}

p = itertools.product(range(1, 100), range(1, 100), range(1, 100))

for x, y, z in p:
    cnt = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (x * z)
    ans_d[cnt] += 1

for i, j in ans_d.items():
    print(i,j)
    if i == n:
        break

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 and z != x:
            cnt += 6
          elif x == y == z:
            cnt += 1
          else:
            cnt += 3
  ans.append(cnt)
for j in range(n):
  print(ans[j])

Submission status: Wrong Answer

Solution code:
N=int(input())
C=[0]*(2*N + 1)
l=10**2
for i in range(l):
    for j in range(l):
        for k in range(l):
            x=i+1
            y=j+1
            z=k+1
            s=(x+y)*(x+y)+(x+z)*(x+z)+(z+y)*(z+y)
            if(s<2*N):
                C[s]+=1
for i in range(N):
    print(C[2*(i+1)])

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,N+1)])
#Heihou_3 = [i**2 for i in range(4,N+1) if i%3 != 0]
n_list = np.array([])
for i in range(1,N//100 +30):
    for j in range(1,N//100 +30):
        n_list = np.append(n_list,3*(i)**2 + 2*i*j + j**2)

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

cnt = 0

for n in range(1,N+1):
    for z in range(1,35):
        for y in range(1,35):
            for x in range(1,35):
                if x*x+y*y+z*z+x*y+y*z+z*x == n:
                    cnt +=1
    print(cnt)
    cnt=0

Submission status: Wrong Answer

Solution code:

import itertools

N = int(input())

ans = [0]*N

x = []


i=1
while 1:
    if (i+1)*(i+1)+2>=N:
        break
    i+=1

for inputI in range(i):
    x.append(inputI+1)


S = list(itertools.combinations_with_replacement(x, 3))


for s in S:
    sum = (s[0]+s[1])*(s[0]+s[2])+pow(s[1],2)+pow(s[2],2)

    if sum <= N:
        if s.count(s[0])==3:
            ans[sum-1]=1
        elif s.count(s[0])==2 or s.count(s[1])==2:
            ans[sum-1]=3
        else:
            ans[sum-1]=6


print(ans)

Submission status: Wrong Answer

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

com = []
for i in range(1,42):
  for j in range(i,42):
    for k in range(j,42):
      com.append([i,j,k])

ls = []
for a,b,c in com:
  ls.append((a**2+b**2+c**2+a*b+b*c+c*a))

for i in range(1,N+1):
  ans = 0
  if i in ls:
    j = ls.index(i)
    k = com[j]
    if k[0] == k[1] and k[1] == k[2] and k[2] == k[0]:
      ans += 1
    elif k[0] == k[1]  or k[1] == k[2] or k[2] == k[0]:
      ans += 3
    elif k[0] != k[1] and k[1] != k[2] and k[2] != k[0]:
      ans += 6
    print(ans)
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
import math

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

    end = N

    for i in range(3,end+1):
        sn = i
        x = 1
        y = 1
        z = sn - 2
        if(cal(x,y,z) < N):
            ans[cal(x,y,z)] += func(i,x,y,z)
        while True:
            y += 1
            z -= 1
            if x > z or y > z:
                break
            if(cal(x,y,z) < N):
                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
                if(cal(x,y,z) < N):
                    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
    elif x != y and y != z and z != x:
        return 6
    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())
lst=[0]*10010
for i in range(1, 41):
  for j in range(1, i+1):
    for k in range(1, j+1):
      temp=i**2+j**2+k**2+i*j+j*k+k*i
      if i==j and j==k:
        lst[temp+1]+=1
      elif i==j and j!=k:
         lst[temp+1]+=3
      elif j==k and k!=i:
         lst[temp+1]+=3
      elif k==i and i!=j:
         lst[temp+1]+=3
      elif i!=j and j!=k:
         lst[temp+1]+=6
for p in range(n+1):
  print(lst[p+1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
f = [0] * N
for i in range(1, N+1):
  count = 0
  for x in range(1, i):
    for y in range(x, i):
      z = i-x-y
      if z < y:
        break
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if n > N:
        break
      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
      #print(x,y,z)
for i in f:
  print(i)

Submission status: Wrong Answer

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

anslist = [0] * 10**4
for i in range(1, int(math.sqrt(int(10000/3)))+1):
    x = i
    for j in range(i, int(math.sqrt(int((10000-i**2)/2)))+1):
        y = j
        for k in range(j, int(math.sqrt(10000-i**2-j**2))+1):
            z = k
            uhen = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if uhen-1 >= 10**4:
                continue
            if x == y == z:
                anslist[uhen-1] = 1
            elif x != y and x != z and y != z:
                anslist[uhen-1] = 6
            else:
                anslist[uhen-1] = 3


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

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    ans = [0] * (10 ** 5)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if x == y and y == z:
                    ans[n - 1] = 1
                elif x != y and y != z and z != x:
                    ans[n - 1] = 6
                else:
                    ans[n - 1] = 3
 
    s = [print(i) for i in ans[0 : N]]

                    
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

b = 1
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(b,N+1):
            sum = i**2 + j**2 + k**2 + i*j + i*k +j*k
            if sum >= N: break
            print(i,j,k)
            if i==j==k: record[sum] += 1
            else: record[sum] += 3
        b += 1

for num in record[1:N+1]:
    print(num)

Submission status: Wrong Answer

Solution code:
n = int(input())

lis = [0] * (10**4 + 1)

for i in range(1, 61):
    for j in range(1, 61):
        for k in range(1, 61):
            t = i**2 + j**2 + k**2 + i*j + j*k + i*k
            tmp = [i,j,k]
            
            if t <= 10**4:
                if len(set(tmp)) == 1:
                    lis[t-1] = 1
                elif len(set(tmp)) == 2:
                    lis[t-1] = 3
                elif len(set(tmp)) == 3:
                    lis[t-1] = 6

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

Submission status: Wrong Answer

Solution code:
from math import trunc, sqrt

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

def perm(x,y,z):
    if x==y and y==z and z==x:
        return 1
    if x!=y and y!=z and z!=x:
        return 6
    return 3

def f(n):
    mn=n
    k=0
    for x in range(1,mn+1):
        for y in range(x,mn+1):
            for z in range(y,mn+1):
                if p(x,y,z)==n:
                    k += perm(x,y,z)
    return k

N=int(input())

for n in range(1,N):
    print(f(n))

Submission status: Wrong Answer

Solution code:
N = int(input())

cnt = 0

for n in range(1,N+1):
    for z in range(1,34):
        for y in range(1,34):
            for x in range(1,34):
                if x*x+y*y+z*z+x*y+y*z+z*x == n:
                    cnt +=1
    print(cnt)
    cnt=0

Submission status: Wrong Answer

Solution code:
import sys
import itertools
import math

if __name__ == "__main__":
    N = int(sys.stdin.readline())

    for i in range(1, N+1):
        ans = 0
        ls = range(1, int(math.sqrt(i)))
        # ls = range(1, int(math.sqrt(i))-2*i)
        # print(ls)
        for (x,y,z) in itertools.combinations_with_replacement(ls, 3):
            tmp = x**2+y**2+z**2+x*y+y*z+z*x
            if tmp > i:
                break
            elif i == tmp:
                ans += 1
                if x == y and y == z:
                    continue
                elif x == y or y == z or z == x:
                    ans += 3-1
                else:
                    ans += 6-1
        print(ans)

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,N+1)])
#Heihou_3 = [i**2 for i in range(4,N+1) if i%3 != 0]
n_list = np.array([])
for i in range(1,N//100 +10):
    for j in range(1,N//100 +10):
        n_list = np.append(n_list,3*(i)**2 + 2*i*j + j**2)

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

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

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())

for i in range(1, n+1):
    if 9441 < i < 9600:
        print(0)
        continue
    if i > 9600:
        print(0)
        continue
    tmp = 0
    for j in itertools.combinations_with_replacement(range(1, 41), 3):
        x, y, z = j
        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
            print(i, j)
            if x == y == z:
                tmp += 1
            elif x != y != z:
                tmp += 6
            else:
                tmp += 3
    print(tmp)

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(1, n+1):
    x = 1
    count = 0
    while x**2 + 2*x <= i-3:
        for y in range(1, i - (x**2 + 2*x + 3)):
            for z in range(1, i - (x**2 + y**2 + 1 +x*y + y + x)):
                if x**2 + y**2 + z**2 +x*y + y*z + z*x == i:
                    if x == y and y == z and z == x:
                        count += 1
                    elif x == y or y == z or z == 1:
                        count += 3
                    else:
                        count += 6
                    break
            else:
                continue
            break
        else:
            x += 1
            continue
        break
    print(count)

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 (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
                pairs.add(key)
            if z2 >= 1:
                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


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

Submission status: Wrong Answer

Solution code:
from sys import stdin,stdout
from collections import Counter

n=int(stdin.readline().strip())
l=[]
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            l.append((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(i*k))
ld=dict(Counter(l))

for i in range(1,21):
    if i in ld:
        stdout.write(str(ld[i])+'\n')
    else:
        stdout.write("0"+"\n")