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] * 10050
for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            tmp = x*x + y*y + z*z + x*y + y*z + z*x
            if tmp<10050:
                ans[tmp] += 1

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

Submission status: Accepted

Solution code:
N = int(input())
num = [0]*N
for i in range(1,10**2 + 1):
    for j in range(1,10**2 + 1):
        for k in range(1,10**2 + 1):
            ans = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if ans <= N:
                num[ans - 1] += 1
for i in range(N):
    print(num[i])

Submission status: Accepted

Solution code:
n = int(input())
a = [0]*n
s = int(n**(1/2))+1
for i in range(1, s):
    for j in range(1, s):
        for k in range(1, s):
            b = i*i+j*j+k*k+i*j+j*k+k*i-1
            if b < n:
                a[b] += 1
for i in range(n):
    print(a[i])

Submission status: Accepted

Solution code:
N = int(input())
 
def calculate_n(x, y, z):
  n = x**2 + y**2 + z**2 + x*y + y*z + z*x
  return n
l = []
for x in range(1, N):
  for y in range(1, N):
    for z in range(1, N):
      n = calculate_n(x,y,z)
      if n > N:
        break
      else:
        l.append(n)
    if calculate_n(x, y+1, 1) > N:
      break
  if calculate_n(x+1, 1, 1) > N:
    break

import collections
c = collections.Counter(l)
for i in range(1, N+1):
  if i in c:
    print(c[i])
  else:
    print(0)

Submission status: Accepted

Solution code:
import math
n=int(input())
ans=[0]*(10**5)
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):
      ans[((x+y)**2+(y+z)**2+(z+x)**2)//2-1]+=1

for i in range(n):
  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:
def main():
    N = int(input())
    dp = [0] * N
    rt = int(pow(N, 0.5)) + 1
    for i in range(1, rt):
        ii = i * i
        for j in range(1, i + 1):
            iji = ii + j * j + i * j
            if iji + 1 + i + j > N:
                break
            for k in range(1, j + 1):
                c = iji + k * k + (i + j) * k
                if c <= N:
                    if i == j or j == k:
                        l = 3
                        if i == k:
                            l = 1
                    else:
                        l = 6
                    dp[c - 1] += l
                else:
                    break
    print(*dp, sep="\n")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
num = [0 for i in range(7*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):
      f_N = x**2 + y**2 + z**2 + x*y + y*z + z*x
      num[f_N] += 1

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
d = defaultdict(int)
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            a = i*i+j*j+k*k+i*j+j*k+k*i
            d[a] += 1
N = int(input())
for i in range(1,N+1):
    print(d[i])

Submission status: Accepted

Solution code:
n=int(input())
l=[0]*(6*(10**4))
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            l[(x*x+y*y+z*z+x*y+y*z+z*x)-1]+=1
for i in range(n):
    print(l[i])

Submission status: Accepted

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


def xyz():
    count = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                ans[zyx] += 1


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

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):
            a = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if a <= N:
                ans[a]+=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 math import sqrt
n=10**4
an=[0 for i in range(n+1)]
for i in range(1,int(sqrt(n))+1):
    for j in range(i,int(sqrt(n))+1):
        for k in range(j,int(sqrt(n))+1):
            a=i*i+j*j+k*k+i*j+i*k+j*k
            if a<=n:
                if i==j and j==k:
                    an[a]+=1
                elif i==j or j==k or i==k:
                    an[a]+=3
                else: an[a]+=6
n=int(input())
for i in range(1,n+1):
    print(an[i])

Submission status: Accepted

Solution code:
import sys
si = sys.stdin.readline


def main():
    n = int(si())
    ans = [0 for _ in range(10000+1)]
    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 100):
                v = ((x+y+z)**2+x**2+y**2+z**2)//2
                if v > 10000:
                    break
                ans[v] += 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
r=range(1,99)
a=[0]*5**7
for x in r:
 for y in r:
  for z in r:a[x*(x+y+z)+y*(y+z)+z*z-1]+=1
print(*a[:int(input())])