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

Submission status: Accepted

Solution code:
N=int(input())

ans=[0]*N

for x in range(1,int(N**(1/2))):
    for y in range(1,int(N**(1/2))):
        for z in range(1,int(N**(1/2))):
            cnt=x**2+y**2+z**2+x*y+y*z+z*x
            if cnt>N:
                break
            else:
                ans[cnt-1]+=1
for i in range(N):
    print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())

def main():
    ans = [0]*(n+1)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if fn > n:
                    break
                else:
                    ans[fn] += 1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
f=[0]*10000
for i in range(100):
  for j in range(100):
    for k in range(100):
      n=(i+1)**2+(j+1)**2+(k+1)**2+(i+1)*(j+1)+(j+1)*(k+1)+(k+1)*(i+1)  
      if n<=10000:
        f[n-1]+=1
for i in range(N):
  print(f[i])

Submission status: Accepted

Solution code:
N = int(input())
ans = [0] * N
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            tmp = i**2+j**2+k**2+i*j+j*k+k*i
            if tmp <= N:
                ans[tmp-1] += 1
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())

ans = [0 for i in range(10**4+1)]
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
            if n <= 10**4:
                ans[n] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# this is the third task 
from collections import defaultdict
N=int(input())
n=1
s=3
brkLoop=False
while True :
    r=(s)**2-(1)-(1)-(n)
    if ( r >= N ):
        break;  
    else:
        n=n+1   
        s=s+1
out=defaultdict(list)
for (x,y,z) in tuple((i,j,k) for i in range(1, n+1) for j in range (1,n+1) for k in range(1,n+1)):
    r=(x+y+z)**2-(x*y)-(y*z)-(x*z)
    if ( r <= N ):
        out[r].append((x,y,z))
for i in range(1,N+1):
    if ( i in out):
        print (len(out[i]))
    else:
        print(0)

Submission status: Accepted

Solution code:
n = int(input())

count = 0

i = 1

count = 0
limit = 100

nums = [0] * n

for x in range(limit):
    for y in range(limit):
        for z in range(limit):
            cal =  (x + 1) ** 2 + (y + 1) ** 2 + (z + 1) ** 2 + (x + 1) * (y + 1) + (y + 1) * (z + 1) + (z + 1) * (x + 1)
            if(cal > n):
                break
            nums[cal - 1] += 1

for n in nums:
    print(n)

Submission status: Accepted

Solution code:

N = int(input())
myans = [ 0 for n in range(N+1)]
upper = int(N**(2/3))
#print(upper)
for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if v < N+1:
                myans[v] += 1
#print(myans)
for a,b in enumerate(myans):
    if a != 0:
        print(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
xyz = [0] * ((10 ** 4) + 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):
            v = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + x * z - 1
            if v < 10 ** 4 + 1:
                xyz[v] += 1
for i in range(n):
    print(xyz[i])

Submission status: Accepted

Solution code:
a = int(input())

b = [0 for _ in range(10050)]
for x in range(1,105):
  for y in range(1,105):
    for z in range(1,105):
      n = x**2+y**2+z**2+x*y+y*z+x*z
      if n<10050:
        b[n] += 1
      
for i in range(a):
  print(b[i+1])

Submission status: Accepted

Solution code:
n =int(input())
ans =[0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i
			if v<10050:               
				ans[v]+=1
for i in range(n):print(ans[i+1])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from math import sqrt
def main():
    N = int(input())
    A = [0]*(N+1)
    n = int(sqrt(N)) + 1
    for x in range(1, n):
        for y in range(1, n):
            for z in range(1, n):
                tmp = x*x + y*y + z*z + x*y + y*z + z*x
                if tmp <= N:
                    A[tmp] += 1
    for i in range(1,N+1):
        print(A[i])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
f=[0 for i in range(10001)]


for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            tmp=x**2+y**2+z**2+x*y+y*z+z*x
            if tmp >10000:
                continue
            f[tmp]+=1

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

Submission status: Accepted

Solution code:
import math
n=int(input())
num=int(math.sqrt(n))
ans=[0]*(n+1)
for i in range(1,num+1):
    for j in range(1,num+1):
        for k in range(1,num+1):
            v=i*i+j*j+k*k+i*j+i*k+j*k
            if v<=n:
                ans[v]+=1
for i in range(n):
    print(ans[i+1])

Submission status: Accepted

Solution code:
n = int(input())
ans = [0 for _ in range(n+1)]
for x in range(1,int(n**0.5)+1):
    for y in range(1,x+1):
        for z in range(1,y+1):
            if x**2+y**2+z**2+x*y+y*z+z*x<=n:
                if x==y==z:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x] += 1
                if (x==y and y != z) or (y==z and z !=x) or (z==x and x != y):
                    ans[x**2+y**2+z**2+x*y+y*z+z*x] += 3
                if (x!=y) and (y!=z) and (z!=x):
                    ans[x**2+y**2+z**2+x*y+y*z+z*x] += 6
for a in ans[1:]:
    print(a)

Submission status: Accepted

Solution code:
f = [0  for i in range(0, 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:
                f[n] += 1 
N = int(input())
for n in range(1, N+1):
    print(f[n])

Submission status: Accepted

Solution code:
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10050:
				ans[v]+=1
for i in range(n):
	print(ans[i+1])

Submission status: Accepted

Solution code:
N = int(input())

temp = 0
ans = [0] * 100000
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            temp = i*i + j*j + k*k + i*j + j*k + k*i
            ans[temp] += 1

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

Submission status: Accepted

Solution code:
N = int(input())
lis = [0]*N
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x -1
            if ans >= N:
                pass
            else:
                lis[ans] += 1
for i in range(N):
    print(lis[i])

Submission status: Accepted

Solution code:
n = int(input())

nums = [0]*n
a = int(n**0.5)+1
for x in range(1,a):
  for y in range(1,a):
    if x**2 + y**2 + x*y > n: break
    for z in range(1,a):
      s = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if s <= n: nums[s-1] += 1
print(*nums, sep="\n")

Submission status: Accepted

Solution code:
import numpy as np
from itertools import permutations
N = int(input())

counter = np.zeros(N, dtype=int)

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            res = x**2 + y**2 + z**2 + x * y + x * z + y * z
            if res <= N:  
                counter[res - 1] += 1

for c in counter:
    print(c)

Submission status: Accepted

Solution code:
nn = int(input())
number_of_match = [0 for _ in range(10005)]
for xx in range(1,105):
  xxxx = xx**2
  for yy in range(1,105):
    yyyy = yy**2
    xxyy = xx*yy
    for zz in range(1,105):
      result = xxxx + yyyy + (zz)**2 + xxyy + (yy)*(zz) + (zz)*(xx)
      if result < 10005:
        number_of_match[result] += 1
for i in range(1,nn+1):
  print(number_of_match[i])

Submission status: Accepted

Solution code:
N = int(input())
ans = [0]*(N+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            num = x*x + y*y + z*z + x*y + y*z + z*x
            if num>N:
                break
            ans[num] = ans[num] + 1
for m in ans[1:]:
    print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def get_ints():
	return map(int, input().split())
def get_list():
	return list(map(int, input().split()))

n = int(input())
dp = [0 for ans in range(10050)]
for x in range(1, 105):
	for y in range(1, 105):
		for z in range(1, 105):
			v = x*x + y*y + z*z + x*y + y*z + z*x
			if v < 10050:
				dp[v] += 1
for i in range(n):
	print(dp[i + 1])

Submission status: Accepted

Solution code:
N = int(input())
list = []
for i in range(10100):
    list.append(0)

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 <= 10000:
                list[n] += 1
                
for i in range(N):                
    print(list[i+1])

Submission status: Accepted

Solution code:

import itertools

def main():
    
    input_lines_n = input()
    n = int(input_lines_n)
    xyz_max = 100
    l = [0] * 10001
    
    for x, y, z in itertools.product(range(xyz_max), range(xyz_max), range(xyz_max)):
        fn = 0
        if x > 0 and y > 0 and z > 0:
            fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if fn <= n:
                l[fn] += 1
    
    for i in range(1, n+1):
        print(l[i])
                    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = [0] * (n + 1)
for i in range(1, n + 1):
	if i*i > n:
		break
	for j in range(1, n + 1):
		z = i*i + j*j + i*j
		if z > n:
			break
		for k in range(1, n + 1):
			
			if (z + k * k + k*i + k * j) > n:
				break
			a[z + k * k + k*i + k * j] += 1
for i in a[1:]:
	print(i)

Submission status: Accepted

Solution code:
import math

N=int(input())
ARR=[0]*(N+1)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            res=x**2+y**2+z**2+x*y+y*z+z*x
            if res<=N:
                ARR[res]+=1

for i in ARR[1:]:
    print(i)

Submission status: Accepted

Solution code:
# Problem XYZ Triplets

# input
N = int(input())

# initialization
ans_list = [0]*(10**6)

# calc
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ans_list[tmp] += 1

# output
for i in range(1, N+1):
    print(ans_list[i])

Submission status: Accepted

Solution code:
import itertools
N = int(input())
num = int(N**0.5)+1

ans = [0]*(N+1)

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

for x,y,z in itertools.product(range(1, num+1), repeat=3):
    fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if fn > N:
        continue
    else:
        ans[fn] += 1

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

Submission status: Accepted

Solution code:
n = int(input())

import math

N = math.ceil(math.sqrt(n))
from collections import defaultdict
counter = defaultdict(int)

from collections import defaultdict
counter = defaultdict(int)

for x in range(1,N + 1):
    answer_x = x * x
    for y in range(x, N + 1):
        answer_y = answer_x + y * y + x * y
        if answer_y > n:
            continue
        for z in range(y, N + 1):
            answer_z = answer_y + z * z + x * z + y * z
            if answer_z <= n:
                if x == y and x == z:
                    counter[answer_z] += 1
                elif x == y or x == z or y == z:
                    counter[answer_z] += 3
                else:
                    counter[answer_z] += 6

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

Submission status: Accepted

Solution code:
n=int(input())
l = [0] * 10001
for a in range(1, 101):
    for b in range(1,101):
        for c in range(1, 101):
            o = a**2 + b**2 + c**2 + a*b + a*c + c*b
            if o <= 10000:
                l[o] += 1
for i in range(1, n+1):
    print(l[i])

Submission status: Accepted

Solution code:
n = int(input())

l = [0] * 10001

for i in range(1, 101):
	for j in range(1, 101):
		for k in range(1, 101):
			x = i**2 + j**2 + k**2 + i*j + j*k + i*k
			if x <= 10000:
				l[x] += 1

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

Submission status: Accepted

Solution code:
import math
def calc(x, y, z):
    return x * x + y * y + z * z + x * y + y * z + z * x

def calc_combination_num(x, y, z):
    if x == y and y == z:
        # 全部同じ数字なら組み合わせの個数は1個
        return 1
    if x == y or y == z:
        # どれか2つが同じ数字なら組み合わせの個数は3C2 = 3個
        return 3
    # 全部違う数字なら組み合わせの個数は3P2 = 6個
    return 6

N = int(input())

result_map = {}
for i in range(1, N + 1):
    result_map[i] = 0

# x <= y <= zとしてループを回し
for x in range(1, N):
    tempFn1 = calc(x, 0, 0)
    if tempFn1 > N:
        # もう数値は増える一方なのでやる必要なし
        break
    for y in range(x, N):
        tempFn2 = calc(x, y, 0)
        if tempFn2 > N:
            # もう数値は増える一方なのでやる必要なし
            break
        for z in range (y, N):
            fn = calc(x, y, z)
            if fn > N:
                # もう数値は増える一方なのでやる必要なし
                break
            # 組み合わせの個数の算出
            combination_num = calc_combination_num(x, y, z)
            result_map[fn] = result_map[fn] + combination_num

for result in result_map.values():
    print(result)

Submission status: Accepted

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

for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            v = x*x + y*y + z*z + x*y + y*z + z*x
            if v <= 10005:
                ans[v] += 1
for i in range(1, N+1):
    print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      if v<10050:
        ans[v]+=1
for i in range(n):
    print(ans[i+1])

Submission status: Accepted

Solution code:
from collections import defaultdict
ans = defaultdict(int)
N = int(input())

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

Submission status: Accepted

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

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      i=x*x+y*y+z*z+x*y+y*z+z*x
      if i <= n:
        num[i]+=1
        
for i in range(n):
  print(num[i+1])

Submission status: Accepted

Solution code:
n=int(input())
vec=[0 for _ in range(10050)]
for x in range(1,105):
	for y in range (1,105):
		for z in range (1 , 105):
			sum= x*x + y*y + z*z + x*y +y*z + z*x
			if sum<10050:
				vec[sum]+=1
				
for i in range(1,n+1):
	print(vec[i])

Submission status: Accepted

Solution code:
from math import sqrt

N = int(input())
limit = int(sqrt(N))

res = [0] * (N + 1)
for x in range(1, limit+1):
    for y in range(1, limit+1):
        for z in range(1, limit+1):
            val = x * x + y * y + z * z + x * y + y * z + z * x
            if val <= N:
                res[val] += 1
            else:
                break

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

Submission status: Accepted

Solution code:
MAX = pow(10,2)+10
N = int(input())
ans = [0 for _ in range(N+1)] #0indexにしておく

def func(a,b,c):
  return a*a+b*b+c*c+a*b+b*c+c*a
for x in range(1,MAX):
  for y in range(1,MAX):
    for z in range(1,MAX):
      temp = func(x,y,z)
      if temp <= N:
        ans[temp] += 1
for i in range(1,N+1):
  print(ans[i])

Submission status: Accepted

Solution code:
# coding: utf-8
import math
import itertools

n = int(input())

ans = [0] * n

for x, y, z in itertools.product(range(1, int(math.sqrt(n))), range(1, int(math.sqrt(n))), range(1, int(math.sqrt(n)))):
    idx = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if idx <= n:
        ans[idx-1] += 1

print(*ans, sep="\n")

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
# sys.setrecursionlimit(int(pow(10,6)))
# sys.stdout = open("out.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    sys.stdin = open("input.txt", "r")
except:
    pass



  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
# @lru_cache(None)
n=L()[0]
dp=[0 for i in range(n+1)]
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            val=i*i+j*j+k*k+i*j+i*k+j*k
            if val<=n:
                dp[val]+=1
for i in range(1,n+1):
    print(dp[i])

Submission status: Accepted

Solution code:
N = int(input())

ans = [0 for _ in range(100001)]

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 105):
            v = i*i + j*j + k*k + i*j + j*k + k*i
            if v < 10001:
                ans[v] += 1

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

Submission status: Accepted

Solution code:
import math

N = int(input())

#f(n) を以下の 2 つの条件の両方を満たすような 3 つの整数の組 (x,y,z)の個数とします。
# 1≤x,y,z
# x**2 + y**2 + z**2 + xy + yz + zx = n

# x,y,zの最大値を考える。
# x**2 + 1**2 + 1**2 + x + 1 + x = n
# x**2 + 2x = n - 3
# x**2 + 2x -n + 3 = 0
# x = {-2 ± sqrt(2**2 - 4*1*(-n+3))}/2*1
# x = {-2 ± sqrt(4 + 4n -12)}/2
# 1 ≤ xより
# x = {-2 + sqrt(4n - 8)}/2 = {-2 + 2 * sqrt(n - 2)}/2 = -1 + sqrt(n - 2)
# ∴ 1 ≤ x ≤ math.floor(-1 + sqrt(n - 2))
# y,zも同様。
# N <= 10**4 より、x,y,xで全探索しても(10**2)**3 = 10**6 で間に合う

ans_dict = {i:set() for i in range(1,N+1)}

if N != 1:
    for i in range(1,1 + math.floor(-1 + math.sqrt(N - 2))):
        for j in range(1,1 + math.floor(-1 + math.sqrt(N - 2))):
            for k in range(1,1 + math.floor(-1 + math.sqrt(N - 2))):
                n = i**2 + j**2 + k**2 + i*j + j*k + k*i
                if 1 <= n <= N:
                    ans_dict[n].add((i,j,k))
                
    for i in range(1,N+1):
        print(len(ans_dict[i]))
else:
    print(0)