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:
N = int(input())
def ff(x,y,z):
    n = x**2+y**2+z**2+x*y+y*z+z*x
    return n
maxx=99

c=[]
ans = [0]*N
for i in range(1,maxx+1):
    for j in range(1,maxx+1):
        for k in range(1,maxx+1):
            r=ff(i,j,k)
            c.append(r)
cc = [i for i in c if i<=N]

for i in cc:
    ans[i-1] += 1

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    f = [0 for i in range(n+1)]
    Max = n**0.5
    Max = int(Max//1) 
    for x in range(1,Max):
        for y in range(1,Max):
            for z in range(1,Max):
                tmp = x**2+y**2+z**2+x*y+y*z+x*z
                if tmp<=n:
                    f[tmp] += 1
    for i in range(1,n+1):
        print(f[i])

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
lst = [0]*(n+1)
for x in range(1, 10**2+1):
    for y in range(1, 10**2+1):
        for z in range(1, 10**2+1):
            if 1 <= x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
                lst[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
for i in range(1, n+1):
    print(lst[i])

Submission status: Accepted

Solution code:
n = int(input())

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

for i in range(1, 100+1):
  for j in range(1, 100+1):
    for k in range(1, 100+1):
      tmp = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if tmp <= 10**4:
        array[tmp] += 1
        
for i in range(1, n+1):
  print(array[i])

Submission status: Accepted

Solution code:
N = int(input())

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

def hantei(x, y, z):
    if x==y and x==z:
        return 1
    elif x==y or x==z or z==y:
        return 3
    else:
        return 6
    
    
for n in range(N):
    x = 1
    cnt = 0
    while func(x, 1, 1) <= n+1:
        y = x
        while func(x, y, 1) <= n+1:
            z = y
            while func(x, y, z) <= n+1:
                if func(x, y, z) == n+1:
                    cnt += hantei(x, y, z)
                z += 1
            y += 1
        x += 1
    print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
from math import floor,sqrt
sqset=set()
for i in range(1,200):
  sqset.add(i**2)
def func(m):
  r=0
  for x in range(1,floor(sqrt(m))+1):
    for y in range(1,floor(sqrt(m))+1):
      a=x+y
      b=x**2+y**2+x*y-m
      d=a**2-4*b
      if d in sqset:
        if (sqrt(d)-a)>0 and (sqrt(d)-a)%2==0:
          r+=1
  return r
for i in range(1,n+1):
  print(func(i))

Submission status: Accepted

Solution code:
n = int(input())

o_list = [0]*n

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if n < x**2+y**2+z**2+x*y+y*z+z*x:
        break
      o_list[x**2+y**2+z**2+x*y+y*z+z*x-1] += 1

for o in o_list:
  print(o)

Submission status: Accepted

Solution code:
import math

n = int(input())
a = [0 for _ in range(n+1)]

x = 1
y = 1
z = 1

for x in range(1,int(math.sqrt(n))+1):
  for y in range(1,int(math.sqrt(n - x**2))+1):
    for z in range(1,int(math.sqrt(n - x**2 - y**2))+1):
      left = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if left <= n:
        a[left] += 1
#        print(x,y,x,left)
      z += 1
    y += 1
  x += 1

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

Submission status: Accepted

Solution code:
import sys
from itertools import permutations as pm
from math import factorial as fact
si = sys.stdin.readline


def main():
    ans = dict()
    n = int(si())
    for x in range(1, 100):
        for y in range(x, 100):
            for z in range(y, 100):
                value = ((x+y+z)**2+x**2+y**2+z**2)//2
                if value > 10000:
                    break
                if x == y and y == z:
                    cases = 1
                elif x != y and y != z and z != x:
                    cases = 6
                else:
                    cases = 3
                if value in ans:
                    ans[value] += cases
                else:
                    ans[value] = cases

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

lis = []

for k in range(1,101):
    for l in range(1,101):
        for m in range(1,101):
            lis.append(k ** 2 + l ** 2 + m ** 2 + k * l + l * m + m * k)

c = collections.Counter(lis)
for p in range(1, n + 1):
    print(c[p])

Submission status: Accepted

Solution code:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()

def solve(n):
    ret = {i:[] for i in range(n+1)}
    X=int(n**(1/2) +0.5)+1
    Y=int(n**(1/2) +0.5)+1 
    Z=int(n**(1/2) +0.5)+1
    for x in range(1,X):
        for y in range(1,Y):
            d = x**2+y**2+x*y
            for z in range(1,Z):
                if n < d+z**2 + y*z + z*x:
                    continue
                ret[d+z**2 + y*z + z*x].append((x,y,z))
    return ret

ret = solve(N)
for i in range(1,N+1):
    print(len(set(ret[i])))

Submission status: Accepted

Solution code:
n = int(input())
o = n // 5
if n > 1000:
    o =n //100
a = [0]* n * 2
for i in range(1,o):
    for j in range(1,o):
        for k in range(1,o):
            num = i * i + j * j + k * k + i * j + j * k + k * i
            if  num > n:
                break
            a[num-1] +=1
           # print("#" + str(num)+" "+str(i) + " " + str(j) + " "+ str(k))
for  i in range(n*2):
    if i >= n:
        break
    print(a[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [0]*10**4
ans = 0
for i in range(1, 101):
  for j in range(1, min(i+1,101)):
    for k in range(1, min(j+1, 101)):
       if (i+j+k)**2-i*j-j*k-k*i <= 10**4:
          p = (i+j+k)**2-i*j-j*k-k*i
          if i==j==k:
             a[p-1] +=1
          elif i != j and j != k:
             a[p-1] +=6
          else:
             a[p-1] +=3
for q in a[:n]:
  print(q)

Submission status: Accepted

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

list1=[0 for i in range(N)]

for x in range(1,n1) :
  for y in range(1,n1) :
    for z in range(1,n1) :
      k=x*x+y*y+z*z+x*y+y*z+z*x
      if k<=N :
        list1[k-1]+=1
for item in list1 :
  print(item)

Submission status: Accepted

Solution code:
n = int(input())
arr = [0] * 60000
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            n_ = x**2 + y**2 + z**2 + x*y + y*z + z*x
            arr[n_-1] += 1

print(*arr[:n], sep='\n')

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
l = []
for i in range(2,144):
    l.append(i)
dic = defaultdict(int)
for i in range(142):
    for j in range(i, 142):
        for k in range(j, 142):
            
            if (l[i]+l[j]+l[k])%2==0 and 2+l[i]<=l[k]+l[j] and 2+l[k]<=l[i]+l[j] and 2+l[j]<=l[i]+l[k]:
                
                if i==j and j==k:
                    dic[l[i]**2+l[j]**2+l[k]**2]+=1
                elif i==j or j==k or i==k:
                    dic[l[i]**2+l[j]**2+l[k]**2]+=3
                else:
                    dic[l[i]**2+l[j]**2+l[k]**2]+=6

for i in range(1, n+1):
    print(dic[2*i])

Submission status: Accepted

Solution code:
N=int(input())

a=[0]*60001

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

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

Submission status: Accepted

Solution code:
N = int(input())

l = [0 for _ in range(N)]
for x in range(1, 10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            m = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if m <= N:
                l[m - 1] += 1
            else:
                break

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

Submission status: Accepted

Solution code:
from collections import Counter
import math
def main():
    n = int(input())
    ans = []
    for x in range(1, int(math.sqrt(n+1))+1):
        for y in range(1, int((math.sqrt(n+1)))+1):
            for z in range(1, int((math.sqrt(n+1)))+1):
                ans.append(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)
    counter = Counter(ans)
    for i in range(1, n+1):
        print(counter[i])
 
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

N = int(input())

dp = []
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
            if a <= N:
                dp.append(a)

dpc = collections.Counter(dp)

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

Submission status: Accepted

Solution code:
N = int(input())
d = {i+1: 0 for i in range(N)}
for i in range(1, int(N**0.5)):
    for j in range(1, i+1):
        for k in range(1, j+1):
            n = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if n > N:
                continue
            if len(set([i, j, k])) == 1:
                d[n] +=  1
            elif len(set([i, j, k])) == 2:
                d[n] +=  3
            else:
                d[n] +=  6
for i in range(N):
    print(d[i+1])

Submission status: Accepted

Solution code:
from math import *
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
for x in range(1,n+1):
    ans = 0
    m = ceil(sqrt(x))+1
    for i in range(1, m):
        for j in range(i, m):
            tmp = (i+j)**2 - 4*(i**2+j**2+i*j-x)
            if tmp > (i+j)**2:
                k = ( -(i+j) + sqrt(tmp) ) // 2
                if k >= j and i**2 + j**2 + k**2 + i*j + j*k + k*i == x:
                    if i == j == k:
                        ans += 1
                    elif i == j or j == k or k == i:
                        ans += 3
                    else:
                        ans += 6
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ls=[0]*n
x=1
y=1
z=1
p=6
m=int(n**0.5)
for x in range(1,m+3):
  for y in range(1,x+1):
    for z in range(1,y+1):
      k=6
      if x==y or y==z:
        k=3
        if x==z:
          k=1
      j=x*x+y*y+z*z+x*y+y*z+x*z
      if j<=n:
        ls[j-1]+=k
      else:
        break
for i in ls:
  print(i)

Submission status: Accepted

Solution code:
""" C
    https://atcoder.jp/contests/aising2020/tasks/aising2020_c
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N):
    maxi = int(math.sqrt(N))
    result = dict()
    for x in range(1, maxi+1):
        for y in range(1, maxi+1):
            for z in range(1, maxi+1):
                n = pow(x, 2) + pow(y, 2) + pow(z, 2) + x*y + y*z + z*x
                if n not in result.keys():
                    result[n] = 1
                else:
                    result[n] += 1

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

if __name__ == "__main__":
    _N = readInteger()

    main(_N)

Submission status: Accepted

Solution code:
import math

N = int(input())

ans = [0 for i in range(N)]
for x in range(1, int(math.sqrt(N))+1):
    for y in range(1, int(math.sqrt(N))+1):
        for z in range(1, int(math.sqrt(N))+1):
            tmp = x*x+y*y+z*z+x*y+y*z+z*x
            if tmp <= N:
                ans[tmp-1] += 1

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

Submission status: Accepted

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

for i in range(1,n+1):
	if 1+2*i*i+i+i+i*i>n:
		e=i
		break;
#print(e)

for i in range(d):
	x=i+1
	y=x
	z=x
	for j in range(i,e):
		y=j+1
		z=y
		for k in range(j,n):
			z=k+1
			#print(x,y,z)
			b=x*x+y*y+z*z+x*y+y*z+z*x
			if b>n:
				c=1
				break;
			if x!=y and y!=z and z!=x:
				ans[b-1]+=6
			elif (x==y and x!=z) or (y==z and x!=y):
				ans[b-1]+=3
			elif x==y and y==z:
				ans[b-1]+=1
		#if c==1:
			#break;
	#if c==1:
		#break;


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

Submission status: Accepted

Solution code:
from itertools import product
N = int(input())
lis = [0]*(N+1)
numlist = [i for i in range(1,100)]
for x,y,z in product(numlist, repeat=3):
    q = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if q <= N:
        lis[q] += 1
for i in lis[1:]:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
xyz = [[[0 for i in range(101)] for j in range(101)] for k in range(101)]
ans = [0 for i in range(n+1)]

def gen_n(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            num = gen_n(i, j, k)
            if n >= num:
                ans[num] += 1
for i in range(1, n+1):
    print(ans[i])

Submission status: Accepted

Solution code:
from math import sqrt

N = int(input())
max_val = int(sqrt(N))


def memo():
    n = 0
    mm = {}
    for x in range(1, max_val):
        for y in range(1, max_val):
            for z in range(1, max_val):
                n = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if mm.get(n) is None:
                    mm[n] = [(x, y, z)]
                else:
                    mm[n].append((x, y, z))
                if n > N:
                    break
    return mm


mm = memo()
for i in range(1, N+1):
    c = mm.get(i)
    if c is None:
        print(0)
    else:
        print(len(c))

Submission status: Accepted

Solution code:
N=int(input())
ANS=[0]*(10**6)
count=0
c=1
for i in range(1,100):
    for j in range(1,100):
        for z in range(1,100):
            c=i**2+j**2+z**2+i*j+j*z+z*i
            ANS[c]+=1
for i in range(1,N+1):
    print(ANS[i])

Submission status: Accepted

Solution code:
import numpy as np

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


def main():
    N = int(input().rstrip())
    ans = np.zeros(N, dtype=np.int64)

    for x in range(1, 143):
        for y in range(x, 143):
            for z in range(y, 143):
                val = (x+y)**2 + (x+z)**2 + (y+z)**2
                if(val <= 2*N and val%2==0):
                    ans[int(val/2)-1] += eval(x, y, z)

    for a in ans:
      print(a)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
"""
yとzで残り
"""
memo = {}
from math import sqrt
for x in range(1,int(sqrt(N))+1):
    for y in range(1,int(sqrt(N))+1):
        for z in range(1,int(sqrt(N))+1):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n not in memo:
                memo[n] = 0
            memo[n] += 1

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

Submission status: Accepted

Solution code:
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    N = int(stdin.readline().rstrip())
    a = {i:0 for i in range(10001)}
    
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                n = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if n <= 10000:
                    a[n] += 1
    for i in range(1,N+1):
        print(a[i])
                    
main()

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())

counter = [0] * 10001
for x in range(1, N+1):
    n1 = x * x
    if n1 >= N:
        continue
    for y in range(x, N+1):
        n2 = n1 + y * y + x * y
        if n2 >= N:
            continue
        for z in range(y, N+1):
            n = n2 + z * z + y * z + z * x
            if 1 <= n <= 10000:
                s = len(Counter([x, y, z]))
                if s == 1:
                    counter[n] += 1
                elif s == 2:
                    counter[n] += 3
                elif s == 3:
                    counter[n] += 6
for i in range(1, N+1):
    print(counter[i])

Submission status: Accepted

Solution code:
import math
n=int(input())
if n <= 5:
  for i in range(n):
    print(0)
else:
  ans=[0]*n
  m=int(math.sqrt(n))-1
  for i in range(1,m+1):
    for j in range(i,m+1):
      for k in range(j,m+1):
        a=(i+j+k)**2-i*j-j*k-k*i
        if a<=n:
          if i==j and j==k:
            ans[a-1]+=1
          elif i!=j and j!=k and k!=i:
            ans[a-1]+=6
          else:
            ans[a-1]+=3
  for i in ans:
    print(i)