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: Wrong Answer

Solution code:
from numba import jit
nn = int(input())


@jit
def aa(nn):
    max_num = 60
    ans_L = []
    for n in range(1,nn+1):
        ans = 0
        for x in range(1,max_num):
            for y in range(1,max_num):
                for z in range(1,max_num):
                    if x**2 + y**2 + z**2 + x*y + y*z + x*z == n:
                        ans += 1

        ans_L.append(ans)
    return ans_L

ans_L = aa(nn)
for i in ans_L:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())

for n in range(1, N+1):
  for x in range(1, 10**2):
    for y in range(1, 10**2):
      answer = 0
      if 3* x**2 + y**2 + 2*x*y == n:
        num_pair = [x, y]
        if num_pair[0] == num_pair[1]:
          answer = 1
          break
        else:
          answer = 3
          break
    break

  print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
L=[0]*N
for x in range(1,150):
    for y in range(x,150):
        for z in range(y,150):
            f=x**2+y**2+z**2+x*y+y*z+z*x
            if f<=N:
                if x==y==z:
                    L[f-1]+=1
                else:
                    L[f-1]+=3
for i in range(N):
    print(L[i])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
f = [0] * N
for i in range(1, N+1):
  count = 0
  for x in range(1, i):
    for y in range(x, i):
      z = i-x-y
      if z < y:
        break
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if n > N:
        break
      if x == y and x == z:
        f[n-1] += 1
      elif x == y or y == z:
        f[n-1] += 3
      elif x != y and x != z:
        f[n-1] += 6
for i in f:
  print(i)

Submission status: Wrong Answer

Solution code:
from math import sqrt

n = int(input())
lim_n = int(sqrt(n))
result = [0] * n

for i in range(2, lim_n+1):
    for j in range(2, i+1):
        for k in range(2, j+1):
            p = i**2+j**2+k**2
            if p >= 2*n:
                break
            if p % 2 == 1:
                continue
            if (j + k) - i < 2:
                continue
            if i == j and j == k:
                if i  % 2 ==1:
                    continue
                result[p//2-1] = 1
            elif i != j and j != k:
                result[p//2-1] = 6
            else:
                result[p//2-1] = 3

for item in result:
    print(item)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import itertools
def calculate(x,y,z):
    return x**2+y**2+z**2+x*y+y*z*x

n = int(input())
result_lst = [0] * n

for i,j,k in itertools.product(range(1,n+2),repeat=3):
    result = calculate(i,j,k)
    if result < n:
        result_lst[result] += 1

for i in result_lst:
    print(str(i))

Submission status: Wrong Answer

Solution code:
n = int(input())

nums = [0]*n
m = n//6
for i in range(1,m+1):
  if i**2//6 >= n: continue
  for j in range(i, m+1):
    if i**2 + j**2 + i*j >= n//2: break
    for k in range(j, m+1):
      t = i**2 + j**2 + k**2 + i*j + j*k + i*k
      if t <= n:
        if i == j and i == k: nums[t-1] += 1
        else: nums[t-1] += 3
        
print(*nums, sep="\n")

Submission status: Wrong Answer

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
    x,y,z = 1,1,1
    a = x**2 + y**2 + z**2 +x*y + y*z + z*x

    for x in range(1,int(N**0.5)):
        for y in range(1,int(N**0.5)):
            for z in range(1,int(N**0.5)):
                a = x**2 + y**2 + z**2 +x*y + y*z + z*x
                if a > N:
                    break
                s = set([x,y,z])
                if len(s) == 1:
                    ans[a-1] = 1
                elif len(s) == 2:
                    ans[a-1] = 3
                else:
                    ans[a-1] = 6

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



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
print(cache)
for i in range(1, N+1):
    if i in cache:
        print(cache[i])
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import itertools
def calculate(x,y,z):
    return x**2+y**2+z**2+x*y+y*z*x

n = int(input())
result_lst = [0] * n

for i,j,k in itertools.product(range(1,n+1),repeat=3):
    result = calculate(i,j,k)
    if result < n:
        result_lst[result] += 1

for i in result_lst:
    print(str(i))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
f = [0] * N
for i in range(1, N+1):
  count = 0
  for x in range(1, i):
    for y in range(x, i):
      z = i-x-y
      if z < y:
        break
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if n > N:
        break
      if x == y and x == z:
        f[n-1] += 1
      elif x == y or y == z:
        f[n-1] += 3
      elif x != y and x != z:
        f[n-1] += 6
print(0)
for i in f:
  print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
for i in range(5):
    print(0)
for n in range(6,N+1):
    ans = 0
    for i in range(1,int(n**0.5)):
        for j in range(i,int(n**0.5)):
            for k in range(j,int(n**0.5)):
                if i**2+j**2+k**2+i*j+j*k+k*i==n:
                    if i == j and j == k:
                        ans += 1
                    else:
                        ans += 3
    print(ans)

Submission status: Wrong Answer

Solution code:
input_number = input()
for n in range(int(input_number)):
	n += 1
	count = 0
	for x in range(100):
		for y in range(100):
			for z in range(100):
				function = x*x+y*y+z*z+x*y+y*z+x*z
				if n == function:
					count += 1
	print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
t = [0]*10001
for i in range(1,41):
    t[6*i**2] += 1
for i in range(1,59):
    for j in range(1,59):
        if(i != j):
            a = (i+j)**2 + 2*j**2
            if(a <= 10000):
                t[a] += 3
            else:
                break
for i in range(3,100):
    for j in range(2,i):
        for k in range(1,j):
            a = ((i+j)**2 + (j+k)**2 + (k+i)**2)//2
            if(a <= 10000):
                t[a] += 6
            else:
                break
for i in range(1,n+1):
    print(t[i])

Submission status: Wrong Answer

Solution code:
n=int(input())
count=1
while count<=6:
    print(0)
    count+=1
    if count==6:
        print(1)
        count+=1


root=4
while count<=n:
    thing=int(root/3)+1
    while thing>0:
        s=root-thing
        a=int(s/2)
        b=s-a
        while a>=1 and b>=1:
            ways=len(set([thing,a,b]))
            if ways==1:
                while count<=root**2-(thing*a+a*b+thing*b) and count<=n:
                    if count==root**2-(thing*a+a*b+thing*b):
                        print(1)
                        count+=1
                        break
                    print(0)
                    count+=1
            elif ways==2:
                while count<=root**2-(thing*a+a*b+thing*b) and count<=n:
                    if count==root**2-(thing*a+a*b+thing*b):
                        print(3)
                        count+=1
                        break
                    print(0)
                    count+=1
            else:
                while count<=root**2-(thing*a+a*b+thing*b) and count<=n:
                    if count==root**2-(thing*a+a*b+thing*b):
                        print(6)
                        count+=1
                        break
                    print(0)
                    count+=1
            if a<b:
                a-=1
                b+=1
            else:
                a+=1
                b-=1
        thing-=1
    root+=1

Submission status: Wrong Answer

Solution code:
n=int(input())
for i in range(1,n+1):
    cnt=0
    for x in range(1,101):
        if x**2>i:
            break
        for y in range(1,101):
            if y**2>i:
                break
            elif x**2+y**2>i:
                break
            for z in range(1,101):
                if z**2>i:
                    break
                elif x**2+z**2>i:
                    break
                elif y**2+z**2>i:
                    break
                elif x**2+y**2+z**2>i:
                    break
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    cnt+=1

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

N = int(input())

o = [0] * (N+1)
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            n = int( ((i+j) * (j+k)) + i*i + k*k)
            if n < (N+1):
                o[n] += 1
            if n > 1001:
                break

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import itertools
def calculate(x,y,z):
    return x**2+y**2+z**2+x*y+y*z*x

n = int(input())
result_lst = [0] * n

for i,j,k in itertools.product(range(1,n+1),repeat=3):
    result = calculate(i,j,k)
    if result < n:
        result_lst[result] += 1

for i in result_lst:
    print(str(i) + '\n')

Submission status: Wrong Answer

Solution code:
n=int(input())

for i in range(1,n+1):
  count = 0
  flg = 0
  for x in range(1,200):
    for y in range(x,200):
      for z in range(y,200):
        fn = (x+y)**2 + (y+z)**2 + (z+x)**2
        if fn > 2*i:
          break
        if fn == 2*i:
          flg = 1
          if x != y and y != z and z != x:
            count = 6
          elif z == y and y == z and z == x:
            count = 1
          else:
            count = 3
          break
    if flg == 1:
      flg = 0
      break
  print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
d=dict({i:0 for i in range(1,n+1)})
for s in range(3,301):
    for x in range(1,s+1-2):
        for y in range(1,s+1-x-1):
            z=s-x-y
            if x<y or y<z:
                continue
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if not v in d:
                continue
            if x==y==z:
                d[v]+=1
            else:
                d[v]+=3
for k in d.keys():
    print(d[k])

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())
mylist=[0]*n
a=1
while(6*(a**2)<n):
    a+=1
l=list(range(1,3*a-1))
for c in itertools.product(l,repeat=3):
    sum_num=sum(c)**2-(c[0]*c[1]+c[1]*c[2]+c[2]*c[0])
    if sum_num<n:
        mylist[sum_num-1]+=1
for i in mylist:
    print(i)

Submission status: Wrong Answer

Solution code:
import math
N = int(input()) + 1
#Nroot = int(math.sqrt(N/3))+1
for n in range(1,N):
    count = 0
    if n >= 6:
#        print(Nroot, int(math.pow(n,1/3))-1)
        for x in range(int(math.sqrt(n/3))+1, int(math.sqrt(n/3))-1 , -1):
            for y in range(x,0,-1):
                if (x+2*y)**2 - (2*x + y) * y < n:
                    break
                for z in range(1,y+1):
#                    print((x + y + z)**2 - (x*y + y*z + z*x), n,x,y,z)
#                    print(x,y,z)
                    formula = (x + y + z)**2 - (x*y + y*z + z*x)
                    if formula == n:
                        if x == y and y == z:
                            count += 1
                        else:
                            count += 3
                        break

        print(count)
    else:
        print("0")

Submission status: Wrong Answer

Solution code:
n = int(input())
t = [0]*10001
for i in range(1,41):
    t[6*i**2] += 1
for i in range(1,59):
    for j in range(1,59):
        if(i != j):
            a = (i+j)**2 + 2*j**2
            if(a <= 10000):
                t[a] += 3
            else:
                break
for i in range(3,100):
    for j in range(2,i):
        for k in range(1,j):
            a = ((i+j)**2 + (j+k)**2 + (k+i)**2)//2
            if(a < 10000):
                t[a] += 6
            else:
                break
for i in range(1,n+1):
    print(t[i])

Submission status: Wrong Answer

Solution code:
n=int(input())
d={}
sm=3
a=1
brk=0
ll=[]

while 1:  
  we=sm-a
  for i in range(1,we):
    c=we-i
    b=i
    temp=pow((a+b+c),2)-(a*b+a*c+b*c)
    if temp not in d:
      d[temp]=1
      ll.append(temp)
    else:
      d[temp]+=1
    brk=max(brk,temp)
  if brk>n and a>=sm-2:
    break
  if we==2:
    sm+=1
    a=1
  else:
    a+=1
  
#print(d)
l=[0]*n
ll.sort()
for i in ll:
  if i>n:
    break
  else:
    l[i-1]=d[i]
#print(d)
#print(ll)
for i in l:
  print(i)

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
ans_d = {i: 0 for i in range(1,10087)}

p = itertools.product(range(1, 42), range(1, 42), range(1, 42))

for x, y, z in p:
    cnt = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (x * z)
    ans_d[cnt] += 1

for i, j in ans_d.items():
    print(j)
    if i == n:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

a = [0]* N

x = [i for i in range(1,43)]
y = [i for i in range(1,43)]
z = [i for i in range(1,43)]
ans = []
for i in x:
    for j in y:
        for k in z:
            t = (i**2+j**2+k**2+i*j+j*k+k*i)
            if t <= N:
                a[t-1] += 1
            
for i in range(N):
    print(a[i])

Submission status: Wrong Answer

Solution code:
n = int(input())

num = range(1, int(n ** 0.5) + 1)
from itertools import combinations_with_replacement
table = [0] * n
for i in combinations_with_replacement(num, 3):
    #print(i)
    index = (i[0] + i[1] + i[2]) ** 2 - (i[0] * i[1] + i[0] * i[2] + i[1] * i[2])

    if (i[0] + i[1] + i[2]) ** 2 - (i[0] * i[1] + i[0] * i[2] + i[1] * i[2]) > n:
        continue
    if i[0] == i[1] == i[2]:
        table[index - 1] += 1
    elif i[0] != i[1] != i[2]:
        table[index - 1] += 6
    else:
        table[index - 1] += 3
for i in range(1, n):
    print(table[i])