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())
d=dict({i:0 for i in range(1,n+1)})
for s in range(3,201):
    for x in range(1,s+1-2):
        for y in range(1,s+1-x-1):
            z=s-x-y
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if not v in d:
                continue
            d[v]+=1
for k in d.keys():
    print(d[k])

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

Submission status: Accepted

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

lst = [0]*1000000
l = 0
res = 0

for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            lst[l] = i**2 + j**2 + k**2 + i*j + j*k + k*i
            l += 1

L = collections.Counter(lst)

for h in range(1,N+1):
    print(L[h])

Submission status: Accepted

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+1)):
                C[s]+=1
for i in range(N):
    print(C[2*(i+1)])

Submission status: Accepted

Solution code:
import sys
import math

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    f = [0]*(n+1)
    n_sqrt = int(math.sqrt(n))
    for x in range(1, n_sqrt):
        for y in range(x, n_sqrt):
            for z in range(y, n_sqrt):
                cnt = 0
                if x == y == z:
                    cnt = 1
                elif x != y != z:
                    cnt = 6
                else:
                    cnt = 3
                idx = x*x + y*y + z*z + x*y + y*z + z*x
                if idx <= n:
                    f[idx] += cnt
    ans = '\n'.join(str(v) for v in f[1:n+1])
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Solution code:
N = int(open(0).read())
cache = {}
cnt = 0
c = int(N ** 0.5)
cs = range(1, c)
for x in cs:
    for y in cs:
        for z in cs:
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n in cache:
                cache[n] += 1
            else:
                cache[n] = 1
for i in range(1, N+1):
    if i in cache:
        print(cache[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
N = int(input())

initial = (1,1,1)
queue = []
queue.append(initial)
pointer = 0
answers = [0] * (N + 1)
memo = {}
while pointer < len(queue):
    x, y, z = queue[pointer]
    # print(x, y, z)
    q = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if q < N + 1:
        add = 1
        if x == y and y == z:
            add = 1
        elif x == y or y == z or z == x:
            add = 3
        else:
            add =6
        answers[q] += add

        if x+1>=y and y >=z and (x+1,y,z) not in memo:
            memo[(x+1,y,z)] = 0
            queue.append((x + 1, y, z))
        if x >= y +1 and y + 1 >= z and (x, y+1, z) not in memo:
            memo[(x,y+1,z)] = 0
            queue.append((x, y + 1, z))
        if x >= y and y >= z+1 and (x, y, z+1) not in memo:
            memo[(x,y,z+1)] = 0
            queue.append((x, y, z + 1))
    pointer += 1

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

Submission status: Accepted

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

from math import sqrt
for i in range(1,n+1):
    ans = 0
    for x in range(1,int(sqrt(i))+1):
        for y in range(x,int(sqrt(i))+1):
            if (x+y)**2-4*(x*y+x**2+y**2-i) < 0:
                continue
            z = (-(x+y)+sqrt((x+y)**2-4*(x*y+x**2+y**2-i)))/2
            zz = int((-(x+y)+sqrt((x+y)**2-4*(x*y+x**2+y**2-i)))/2)
            if z == zz and zz >= y:
                if x == y and y == z and x == z:
                    ans += 1
                    #print(i,x,y,zz)
                elif x == y:
                    ans += 3
                elif y == z:
                    ans += 3
                else:
                    ans += 6
    anslist.append(ans)

for ans in anslist:
    print(ans)

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    N = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zer
    ans = [0]*N
    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):
                a = x**2 + y**2 + z**2 +x*y + y*z + z*x
                if a > N:
                    break
                ans[a-1] += 1

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



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())
ans = [0] * n
count = 0
for i in range(n):
    x = i + 1
    xx = x * x
    if  x * x >= n:
        break
    for j in range(n):
        y = j + 1
        yy = y * y
        if xx + yy + x * y>= n:
            break
        for k in range(n):
            z = k + 1
            zz = z * z
            kotae = xx + yy + zz + x * y + y * z + z * x
            if kotae > n:
                break
            ans[kotae-1] += 1
for i in range(n):
    print(ans[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


import collections
import math
def main():

    n = input_int()
    ans = collections.defaultdict(set)
    max_val = int(math.sqrt(n)) + 1
    for x in range(1, max_val):
        for y in range(1, max_val):
            for z in range(1, max_val):
                temp = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (x * z) + (y * z)
                if temp <= n:
                    ans[temp].add((x, y, z))

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
ans = [0]*(10**4+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            res = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if res <= 10**4:
                ans[res] += 1


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

Submission status: Accepted

Solution code:
import sys
import numpy as np
import itertools
# from decimal import Decimal
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
# 100 でLoop
ansLis = [0] * 10001
arr = np.array(ansLis)

for i in range(1, 100):
    for j in range(i, 100):
        for k in range(j, 100):
            tar = i*i + j*j + k*k + i*j + j*k + k*i
            if (tar > 10000):
                continue

            if (i == j and j == k):
                arr[tar] += 1
            elif (i != j) and (j != k):
                arr[tar] += 6
            else:
                arr[tar] += 3


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