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: Accepted

Solution code:
from itertools import combinations_with_replacement
n=int(input())
ans=[0]*100000
list1=list(combinations_with_replacement(list(range(1,100)), 3))
for i in range(len(list1)):
    x=list1[i][0]
    y=list1[i][1]
    z=list1[i][2]
    if len(list(set(list1[i])))==1:
        ans[(x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(x*z)-1]+=1
    elif len(list(set(list1[i])))==2:
        ans[(x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(x*z)-1]+=3
    else:
        ans[(x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(x*z)-1]+=6
for i in range(n):
    print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
dict = {}
for i in range(0,10001):
  dict[i] = 0
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      tmp = int(((x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2) / 2)
      if tmp <= 10000:
        dict[tmp] = dict[tmp] + 1
for i in range(1,N + 1):
  print(dict[i])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()

	ans=[0]*(10**4+10)

	for x in range(1,105):
		for y in range(1,105):
			for z in range(1,105):
				a=x**2+y**2+z**2+x*y+y*z+z*x
				if a<=10**4:
					ans[a]+=1

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









if __name__ == "__main__":
	main()

Submission status: Accepted

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] = f_list[f(x,y,z)-1] + 1
          else:
            f_list[f(x,y,z)-1] = f_list[f(x,y,z)-1] + 3
        else:
          f_list[f(x,y,z)-1] = f_list[f(x,y,z)-1] + 6

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

Submission status: Accepted

Solution code:
N=int(input())
def fn(N):
  lis=[]
  i=1
  T=-1
  while i**2<=2*N:
    lis.append(i)
    i+=1
  rtn=[0]*N
  for i,a in enumerate(lis):
    for j in range(i,len(lis)):
      b=lis[j]
      for k in range(j,len(lis)):
        c=lis[k]
        tmp=a**2+b**2+c**2
        if tmp%2==0 and tmp<=2*N:
          x,y,z=(a-b+c)/2,(a+b-c)/2,(b+c-a)/2
          if x%1==0 and y%1==0 and z%1==0: 
            if x>0 and y>0 and z>0:
              if x==y and y==z: rtn[int(tmp/2)-1]+=1
              elif x==y or y==z or z==x: rtn[int(tmp/2)-1]+=3
              else: rtn[int(tmp/2)-1]+=6
  return rtn


lis=fn(N)
for i in range(N): print(lis[i])

Submission status: Accepted

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


n = N + 1
m = math.floor(math.sqrt(n))

ans = [0] * (N + 1)
#    print(s , m)        
for x, y, z  in itertools.product(range(1, m+1), repeat=3):
    www = x * x + y * y + z* z + x*y + y *z + z * x
    if www <= N :
        ans[x * x + y * y + z* z + x*y + y *z + z * x] += 1

ans = ans[1:]
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import collections
n = int(input())
l = [0]*250939
count = 0
for x in range(1,500):
    for y in range(1,500):
        for z in range(1,500):
            tmp = (x+y+z)**2-(x*y+y*z+z*x)
            if tmp <= 10**4:
                l[count] = tmp
                count+=1
            else:
                break
l = sorted(l)
C = collections.Counter(l)
for j in range(1,n+1):
    print(C[j])

Submission status: Accepted

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: Accepted

Solution code:
import numpy as np

N = int(input())
res = np.zeros(N+1)

th = int(np.sqrt(N)) + 1
for x in range(1, th):
    for y in range(1, x + 1):
        for z in range(1, y + 1):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if n > N:
                continue
            if x == y and y == z:
                res[n] += 1
            elif x == y or y == z or z == x:
                res[n] += 3
            else:
                res[n] += 6
for i in range(1, N+1):
    print(int(res[i]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())

cnt = [0]*n

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            if x**2 + y**2 + z**2 + x*y + x*z + y*z - 1 < n:
                cnt[x**2 + y**2 + z**2 + x*y + x*z + y*z - 1] += 1
print(*cnt,sep='\n')

Submission status: Accepted

Solution code:
def main():
    N = int(input())

    f = [0] * (N+1)

    for x in range(1, 100):
        for y in range(x, 100):
            for z in range(y, 100):
                if (ans := (x+y+z)**2 - x*y - y*z - z*x) in range(1, N+1):
                    count = 0
                    if x == y and y == z:
                        count = 1
                    elif x != y and y != z and z != x:
                        count = 6
                    else:
                        count = 3
                    f[ans] += count
    
    for i in range(1, N+1):
        print(f[i])




def input_ints():
    line_list = input().split()

    if len(line_list) == 1:
        return int(line_list[0])
    else:
        return map(int, line_list)


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
from itertools import combinations_with_replacement as cwr
#======================================================#
def main():
    n = II()
    # (x+y+z)^2 - n = xy + yz + zx
    lst = [1]
    ans = {i:0 for i in range(1,n+1)}
    for x,y,z in cwr(range(1,100),3):
        p = (x+y+z)**2 - (x*y + y*z + z*x)
        if p <= n:
            if x == y == z:
                ans[p] += 1
            elif x != y and y != z:
                ans[p] += 6
            else:
                ans[p] += 3
    for k,v in ans.items():
        print(v)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

ans = [0] * (N+1)

for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            tmp = i**2+j**2+k**2+i*j+j*k+k*i
            if 1 <= tmp <= N:
                ans[tmp] += 1
for i in range(1, N+1):
    print(ans[i])

Submission status: Accepted

Solution code:
from itertools import combinations_with_replacement
from itertools import product

def func(a,b,c):
  return a**2+b**2+c**2+a*b+b*c+c*a

num=list(range(1,42))
n = int(input())
p = 0
dic = {}
for i in list(product(range(1,100), repeat=3)):
  r = func(i[0], i[1], i[2])
  if r in dic:
    dic[r] += 1
  else:
    dic[r] = 1
for d in range(1,n+1):
  if d in dic:
    print(dic[d])
  else:
    print(0)

Submission status: Accepted

Solution code:
from copy import copy


def conditions(xyz):
    x, y, z = xyz
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


def plus_num(comb):
    if len(set(comb)) == 1:
        return 1
    elif len(set(comb)) == 2:
        return 3
    elif len(set(comb)) == 3:
        return 6


N = int(input())

candidate = range(1, 100)
result = {}
for i in candidate:
    for j in range(i, 100):
        for k in range(j, 100):
            cal = conditions((i, j, k))
            if cal <= N:
                if cal in result:
                    result[cal] += plus_num((i, j, k))
                else:
                    result[cal] = plus_num((i, j, k))

for i in range(1, N + 1):
    if i in result:
        print(result[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
N = int(input())
A = [0]*10000
for i in range(1,100):
    for j in range(i,100):
        for k in range(j,100):
            if i==j==k and i**2+j**2+k**2+i*j+j*k+k*i <= 10**4:
                A[i**2+j**2+k**2+i*j+j*k+k*i-1] += 1
            elif (i==j or j==k or k==i)and i**2+j**2+k**2+i*j+j*k+k*i <= 10**4:
                A[i**2+j**2+k**2+i*j+j*k+k*i-1] += 3
            elif i**2+j**2+k**2+i*j+j*k+k*i <= 10**4:
                A[i**2+j**2+k**2+i*j+j*k+k*i-1] += 6
for i in range(N):
    print(A[i])

Submission status: Accepted

Solution code:
N=int(input())
S = set([s**2 for s in range(2,int(N**0.5)+1)])
ans = [0]*(N+1)
for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
      n = x*x+y*y+z*z+x*y+y*z+z*x
      if n<=N:
        ans[n]+=1
for v in ans[1:]:
  print(v)

Submission status: Accepted

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

for z in range(1,101):
    for y in range(1,101):
        for x in range(1,101):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            N_list[ans-1] += 1

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

Submission status: Accepted

Solution code:
N = int(input())
 
res = {i+1: 0 for i in range(N)}
 
for i in range(1, int(N**0.5)):
  for j in range(1, int(N**0.5)):
    for k in range(1, int(N**0.5)):
      n = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if n in res:
        res[n] += 1
for r in res.values():
  print(r)

Submission status: Accepted

Solution code:
N = int(input())

DP = [0]*(N+1)

for x in range(1,round(N**0.5)):
    for y in range(1,round(N**0.5)):
        for z in range(1,round(N**0.5)):
            hoge = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x

            if hoge <= N:
                DP[hoge] += 1
            else:
                break

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

Submission status: Accepted

Solution code:
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n = int(readline())
# n = 10**4
# n = 1700 ** 0.5
# print(n)

l = [0]*(10**5)
# 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
#             l[i] += 1

pattern = list(itertools.combinations_with_replacement(range(1, 101), 3))
# print(len(pattern))
# print(pattern[:10:])
for p in pattern:
    x, y, z = p

    i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if len(set(p)) == 3:
        l[i] += 6
    elif len(set(p)) == 2:
        l[i] += 3
    else:
        l[i] += 1

    # print(x, y, z)
# 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
#             l[i] += 1

for j in range(1, n+1):
    print(l[j])
# # print(l[1:100:])
# print(l[1:n:])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input().strip())

x, y, z = 1, 1, 1

f = [0] * (N + 1)

# while x**2 + y**2 + z**2 + x*y + y*z + x*z <= N:
def calc(x, y, z, f, axis="xyz"):
    # print(x, y, z)
    n = x**2 + y**2 + z**2 + x*y + y*z + x*z

    if n <= N:
        f[n] += 1
        if axis == "xyz":
            f = calc(x+1, y, z, f, axis="xyz")
            f = calc(x, y+1, z, f, axis="yz")
            f = calc(x, y, z+1, f, axis="z")
        elif axis == "yz":
            f = calc(x, y+1, z, f, axis="yz")
            f = calc(x, y, z+1, f, axis="z")
        elif axis == "z":
            f = calc(x, y, z + 1, f, axis="z")
        return f
    else:
        return f

f = calc(x, y, z, f)


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

Submission status: Accepted

Solution code:
from itertools import combinations_with_replacement
from collections import defaultdict
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

f = defaultdict(int)
for x,y,z in combinations_with_replacement(range(1, 100), 3):
    l = len(set([x,y,z]))
    num = calc(x,y,z)
    if l == 1:
        f[num] += 1
    elif l == 2:
        f[num] += 3
    else:
        f[num] += 6

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

Submission status: Accepted

Solution code:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
ans = [0] * N

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

for x in range(1, int(N ** 0.5) + 2):
    if fn(x, 1, 1) > N:
        break
    for y in range(1, int(N ** 0.5) + 2):
        if fn(x, y, 1) > N:
            break
        for z in range(1, int(N ** 0.5) + 2):
            f = fn(x, y, z)
            if f > N:
                break
            if f <= N:
                ans[f - 1] += 1

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import itertools

N = int(input())

record = [0] * (10 ** 4 + 1)
for p in itertools.product(range(1, 99), range(1, 99), range(1, 99)):
    x, y, z = p
    n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if n > N:
        continue
    record[n] += 1

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


N = int(input())
count = [0] * N
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            m = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if m > N:
                continue
            count[m - 1] += 1

print('\n'.join(map(str, count)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

cnts=[0 for i in range(N+1)]

for x in range(1,100):
    x2=x*x
    for y in range(x,100):
        y2=y*y
        xy=x*y
        if x2+y*y+x*y+x+y > N:
            break

        for z in range(y,100):
            z2 = z*z
            M = x2+y2+z2+xy+y*z+z*x
            if M > N:
                break
            if x!=y:
                if y!=z:
                    cnts[M]+=6
                else:
                    cnts[M]+=3
            else:
                if y!=z:
                    cnts[M]+=3
                else:
                    cnts[M]+=1

for a in cnts[1:N+1]:
    print(a)

Submission status: Accepted

Solution code:
import math
s = int(input())
ans = [0] * 100000
a = 0
b = 0
c = 0

for i in range(3, 3 * math.floor(math.sqrt(s))):
    for j in range(1, i):
        a = j
        for k in range(1, i - j):
            b = k
            c = i - a - b
            d = a*a + b*b + c*c + a*b + b*c + c*a
            ans[d - 1] += 1

for i in range(s):
    print(str(ans[i]))

Submission status: Accepted

Solution code:
import math
N = int(input())
l = [0] * N
for x in range(1, int(math.sqrt(2 * N))):
    for y in range(1, int(math.sqrt(2 * N))):
        for z in range(1, int(math.sqrt(2 * N))):
            A = int(x * (x + y) +  y * (y + z) + z * (z + x))
            if A <= N:
                l[A - 1] += 1
for i in range(N):
    print(l[i])