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:
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


N = int(input())


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


xyz_dict = defaultdict(int)
num_dict = defaultdict(int)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            num = g(x, y, z)
            if (x, y, z) in xyz_dict:
                continue
            xyz_dict[(x, y, z)] = 1
            num_dict[num] += 1


for n in range(1, N+1):
    print(num_dict[n])

Submission status: Accepted

Solution code:
N = int(input())

anss = [0] * (N+1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            a = x*x + y*y + z*z + x*y + y*z + z*x
            if a <= N:
                anss[a] += 1

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

Submission status: Accepted

Solution code:
n=int(input())
r=range(1,100)
l=[0]*n
for x in r:
  for y in r:
    for z in r:
      t=x*x+y*y+z*z+y*z+z*x+x*y-1
      if t<n: l[t]+=1
for i in l: print(i)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)

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

N = int(input())

CNT = [0] * 10010
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:
                continue

            CNT[f] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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):
            ans[ans_xyz(x, y, z)] += 1
print(*ans[1:N + 1], sep='\n')

Submission status: Accepted

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(1,N+1):
    print(ans[i])

Submission status: Accepted

Solution code:
import collections

n = int(input())
ans_list = []
for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
        ans_list.append(x*x+y*y+z*z+x*y+y*z+z*x)

counter = collections.Counter(ans_list)
for i in range(1,n+1):
  print(counter[i])

Submission status: Accepted

Solution code:
N = int(input())
L = [0 for _ in range(N+1)]
for i in range(1,int(N**0.5)+1):
    for j in range(i, int(N ** 0.5)+1):
        for k in range(j, int(N ** 0.5)+1):
            a = i*i + j*j + k*k + i*j + j*k + k*i
            if a > N:
                break
            elif a >= 0:
                if i == j == k:
                    L[a] += 1
                elif i == j or j == k:
                    L[a] += 3
                else:
                    L[a] += 6
for i in range(1,N+1):
    print(L[i])

Submission status: Accepted

Solution code:
N= int(input())
li=[0]*(N+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            f=x*x + y*y + z*z + x*y + y*z + z*x
            if f<N+1:
                li[f]+=1

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

Submission status: Accepted

Solution code:
n=int(input())
y=[0 for _ in range(10**4+1)]
for j in range(1,100):
   for k in range(1,100):
      for u in range(1,100):
         a=j*j+k*k+u*u+j*k+k*u+u*j
         if a <= 10**4:
            y[a-1]+=1
for o in range(n):
   print(y[o])

Submission status: Accepted

Solution code:
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def f(m):
    res = 0
    r_m = math.sqrt(m)
    for i in range(1, int(r_m) + 1):
        for j in range(1, int(r_m) + 1):
            for k in range(1, int(r_m) + 1):
                if i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i == m:
                    print(f'{(m, i, j, k)=}')
                    res += 1
    return res


n = I()
cnt = [0] * 10001
r_n = int(math.sqrt(n)) + 1
for x in range(1, r_n):
    for y in range(1, r_n):
        for z in range(1, r_n):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if v <= n:
                cnt[v] += 1

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

Submission status: Accepted

Solution code:
N = int(input())
ans = [0] * 100000
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ans[x*x+y*y+z*z+x*y+y*z+z*x-1] += 1
for i in range(N):
    print(ans[i])

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
import math

def run():
    N = int(input())
    for n in range(1, N+1):
        ret = 0
        val = int(math.sqrt(2 * n))
        for X in range(2, val+1):
            for Y in range(2, val+1):
                tmp1 = 2 * n - X ** 2 - Y ** 2
                if tmp1 >= 0 and math.sqrt(tmp1) == int(math.sqrt(tmp1)):
                    Z_ = int(math.sqrt(tmp1))
                    if Z_ != 0:
                        for k in [-1, 1]:
                            Z = Z_ * k
                            if not (X + Y + Z) % 2:
                                xyz = (X + Y + Z) // 2
                                x = xyz - Y
                                y = xyz - Z
                                z = xyz - X
                                if x >= 1 and y >= 1 and z >= 1:
                                    ret += 1
                                    #print(x, y,z)


        print(ret)



if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
N = int(input())

ans = [0]*N

for i in range(1,101,1):
  for j in range(1,101,1):
    for k in range(1,101,1):
      n = i**2+j**2+k**2+i*j+j*k+k*i
      if n > N:
        continue
      ans[n-1]+=1
      
for i in range(N):
  print(ans[i])

Submission status: Accepted

Solution code:

n = int(input())

ans = [0 for _ in range(n+1)]
x = 1
y = 1
z = 1

while True:
    f = x * x + y * y + z * z + x * y + y * z + z * x
    if f > n:
        if z > 1:
            y += 1
            z = 1
        elif y > 1:
            x += 1
            y = 1
        else:
            break
    else:
        ans[f] += 1
        z += 1

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()

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

ans = [0]*(N+1)

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

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

Submission status: Accepted

Solution code:
def g(x, y, z):
    g_xyz = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    return g_xyz


N = int(input())
ans_list = [0 for _ in range(60000)]
for x in range(1, 100):
  for y in range(1, 100):
      for z in range(1, 100):
          ans_list[g(x=x, y=y, z=z) - 1] += 1
           
for i in range(N):
    print(ans_list[i])

Submission status: Accepted

Solution code:
N = int(input())
ans = [0] * 100000
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ans[x*x+y*y+z*z+x*y+y*z+z*x-1] += 1
for i in range(N):
    print(ans[i])

Submission status: Accepted

Solution code:
def f(a,b,c):
    n=(a+b+c)**2 -a*b -b*c -c*a
    return n

N=int(input())

anslist=[0]*1000005

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            n= f(x,y,z)
            anslist[n-1]+=1

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

Submission status: Accepted

Solution code:
N=int(input())
ans=[0]*N
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      temp=x**2+y**2+z**2+x*y+y*z+z*x
      if temp<=N:
        ans[temp-1]+=1
[print(x) for x in ans]

Submission status: Accepted

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

cnt = 0
for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      f = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      if f <= n:
        ans[f - 1] += 1
ans.append(cnt)

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

Submission status: Accepted

Solution code:
import math
N=int(input())
for n in range(1,N+1):
    saidai=math.floor((abs(n-2))**0.5)
    saishou=math.ceil((n//6)**0.5)
    answer=0
    for z in range(saishou,saidai+1):
        if 3+z**2+2*z>n:
            break
        for y in range(1,z+1):
            if y**2+z**2+1+y+z+y*z>n:
                break
            for x in range(1,y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x>n:
                    break

                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x==y==z:
                        answer+=1
                        break
                    elif x==y or y==z or z==x:
                        answer+=3
                        break
                    else:
                        answer+=6
                        break
    print(answer)

Submission status: Accepted

Solution code:
n = int(input())
# 答え用の配列を準備しておく
ans = [0 for i in range(n+1)]
for x in range(1,int(n**0.5+1)):
    for y in range(1,int(n**0.5+1)):
        for z in range(1,int(n**0.5+1)):
            res = x**2+y**2+z**2+x*y+y*z+x*z
            # resの値がn以下ならカウントする
            if res<=n:
                ans[res] += 1
for i in range(1,n+1):
    print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
ls = [0]*(N+2)

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

for p in range(1,N+1):
    print(ls[p])

Submission status: Accepted

Solution code:
import math as m
N=int(input())
ans=[0]*N
if N>5:
    for x in range(1,int(m.sqrt(N-5))+1):
        for y in range(1,x+1):
            if x**2+y**2+x*y+x+y+1>N:
                break
            for z in range(1,y+1):
                if x**2+y**2+x*y+x*z+y*z+z**2>N:
                    break
                if len(list(set([x,y,z])))==3:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=6
                elif len(list(set([x,y,z])))==2:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=3
                elif len(list(set([x,y,z])))==1:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=1

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())

lis = [0] * (n+1)

s = int(n ** 0.5)

for i in range(1, s+1):
    for j in range(1, s+1):
        for k in range(1, s+1):
            t = i**2 + j**2 + k**2 + i*j + j*k + i*k
            tmp = [i,j,k]
            
            if t <= n:
                lis[t] += 1

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