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:
N=int(input())
for n in range(1,N+1):
    a=n/6

    saidai=int(a**0.5)+2
    answer=0
    for z in range(1,saidai+1):
        if 3+z**2+2*z>n:
            break
        for y in range(1,z+1):
            if y**2+z**2+1+y+z+y*z>n:
                break
            for x in range(1,y+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==n:
                    if x==y==z:
                        answer+=1
                        break
                    elif x==y or y==z or z==x:
                        answer+=3
                        break
                    else:
                        answer+=6
                        break
    print(answer)

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
max_list_size = (25 + 25 + 25) ** 3
results = [0] * max_list_size

combinations = list(itertools.product(range(1, 26), repeat=3))
for x, y, z in combinations:
    calc_result = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    results[calc_result] += 1
for i in range(1, n + 1):
    print(results[i])

Submission status: Wrong Answer

Solution code:
N = int(input())

initial = (1,1,1)
queue = []
queue.append(initial)
pointer = 0
answers = [0] * 10001
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
    answers[q] += 1

    pointer += 1
    if q < N:
        if x >= y and x >= z:
            queue.append((x + 1, y, z))
        if y >= z:
            queue.append((x, y + 1, z))
        queue.append((x, y, z + 1))
        
for a in answers[1:21]:
    print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
count = [0] * (10**6)
s = 0

for i in range(1, 10):
    for j in range(1, 10):
        for k in range(1, 10):
            s = i * i + j * j + k * k + i * j + j * k + k * i 
            count[s - 1] += 1
            # if s != 0:
            #     print(i,j,k)
for i in range(n):
    print(count[i])

Submission status: Wrong Answer

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

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

ans = [0] * (N+1)
for x in range(1, math.ceil(N**0.5)):
    for y in range(x, math.ceil(N**0.5)):
        for z in range(y, math.ceil(N**0.5)):
            k = f(x,y,z)
            if k < N:
                if x == y == z:
                    ans[k] += 1
                elif x == y or y == z or z == x:
                    ans[k] += 3
                else:
                    ans[k] += 6
for i in range(1, N+1):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0 for i in range(n)]

for i in range(1,n+1):
  for x in range(1,20):
    for y in range(1,20):
      for z in range(1,20):
        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:
### Problem C
import math

N = int(input())

for x in range(1,N+1):
    cnt = 0
    if N <= 1000:
        up = int(math.sqrt(x))
    elif N > 1000:
        up = int(math.sqrt(x)/1.5)
        for i in range(1,up):
            for j in range(1,up):
                for k in range(1,up):
                    if (i + j + k)**2 == x + (i*j + j*k + k*i):
                        cnt += 1
    print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter

def main(N):
    lst = []
    for x in range(1, 142):
        for y in range(1, 142):
            for z in range(1, 142):
                r = (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2
                if r <= 2 * 10 ** 4:
                    lst.append(r // 2)
                else:
                    break
    c = Counter(lst)
    st = set(lst)

    for n in range(1, N):
        if n in st:
            print(c[n])
        else:
            print(0)


if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Wrong Answer

Solution code:
import math

def xyz(n):
    rng = math.floor(math.sqrt(2 * n))
    count = 0
    for xpy in range(2, rng):
        for ypz in range(2, rng):
            for zpx in range(2, rng):
                if (xpy) ** 2 + (ypz) ** 2 + (zpx) ** 2 == 2 * n:
                    count += 1
    return count


N = int(input())
for i in range(1, N+1):
    print(xyz(i))

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement

N = int(input())
ans = [0] * (N + 1)
for x, y, z in combinations_with_replacement(list(range(1, 50)), 3):
    val = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + x * z
    if x == y and y == z: # 1 1 1 => (1, 1, 1)
        cnt = 1
    if x == y and y != z: # 1 1 2 => (1, 1, 2), (1, 2, 1), (2, 1, 1)
        cnt = 3
    if x != y and y == z: # 1 2 2 => (1, 2, 2), (2, 1, 2), (2, 2, 1)
        cnt = 3
    if x != y and y != z: # 1 2 3 => (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)
        cnt = 6
    
    if val <= N:
        ans[val] += cnt

print('\n'.join(map(str, ans[1:])))

Submission status: Wrong Answer

Solution code:
N = int(input())

def f(n):
    total = 0
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    total += 1
    return total

for i in range(N):
    print(f(i))

Submission status: Wrong Answer

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

N = int(input())
saidai = int(math.sqrt(N))

def g(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

def f(n):
    result = [0] * (n+1)
    for idx, (x, y, z) in enumerate(itertools.product("".join(map(str, (range(1, saidai + 1)))), repeat=3)):
        tmp = g(int(x), int(y), int(z))
        if tmp <= N:
            result[tmp] += 1
    return result

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

Submission status: Wrong Answer

Solution code:
n = int(input())

rng = [0] * (n+1)

for i in range(1,14):
    buf = (i**2)*6
    if buf > n:
        break
    else:
        rng[buf] += 1

for i in range(1,32):
    for j in range(1,32):
        if i==j:
            continue
        buf = i ** 2 + 2 * i * j + 3 * (j ** 2)
        if buf > n:
            break
        else:
            rng[buf] += 3

for i in range(1,30):
    for j in range(i+1,31):
        for k in range(j+1,32):
            buf = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if buf > n:
                break
            else:
                rng[buf] += 6
        if buf > n:
            break

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

Submission status: Wrong Answer

Solution code:


a={}
for i in range(1,45):
    for j in range(1,45):
        for k in range(1,45):
            n=i*i+j*j+k*k+i*j+i*k+j*k
            if i==j and j==k:
                a[n]=1
            elif i==j or j==k or i==k:
                a[n]=3
            elif i!=j and j!=k and k!=i:
                a[n]=6
n=int(input())
for i in range(n):
    if i+1 in a:
        print(a[i+1])
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import deque
from copy import copy

N = int(input())
result = [0]*N

if N < 6:
    for i in range(N):
        print(0)
    exit()

result[5] += 1

coord = deque()
coord.append([[1, 1, 1], 6, 0])

while len(coord):
    sol, ans, level = coord.popleft()
    for i in range(level, 3):
        new_sol = copy(sol)
        new_sol[i] += 1
        new_ans = ans + sum(sol) + sol[i] + 1
        if new_ans < N:
            coord.append([new_sol, new_ans, i])
            result[new_ans-1] += 1

print(*result, sep='\n', end='')

Submission status: Wrong Answer

Solution code:
import itertools
ln = itertools.product(range(1,100),repeat = 3)
#print(ln)
line = [0 for i in range(10000)]
#print(len(line))
for i in ln:
    x,y,z = i
    n = x**2 +y**2 + z**2 +x*y + y*z + z*x
    if n <=1000:
        line[n-1]+=1
N = int(input())
for i in range(N):
    print(line[i])

Submission status: Wrong Answer

Solution code:
N = int(input())

res = [0] * N


for x in range(1, 102):
    for y in range(1, 102):
        for z in range(1, 102):
            t1 = (x + y + z) ** 2

            if t1 > 11000:
                break

            n = t1 - x * y - y * z - z * x - 1
            
            if n >= N:
                break
            res[n] += 1

for o in res:
    print(o)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

L = [0] * (N + 1)
thre =  ceil(sqrt(N)) + 1
# print(thre)
for x in range(1, thre+1):
    for y in range(1, thre + 1):
        for z in range(1, thre + 1):
            if f(x,y,z) < N:
                L[f(x, y, z)] += 1
print(*L[1:], sep="\n")

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline

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

n = int(input())
# ans = []
# for u in range(1, n+1):
#     cnt = 0
#     for i in range(1, int(n/(u**2))+2):
#         for j in range(1,int(u/(i**2))+2):
#             for k in range(1,int(u/(j**2))+2):
#                 if i**2+j**2+k**2+i*j+j*k+k*i == u:
#                     if i == j == k:
#                         cnt += 1
#                     elif i != j and j != k and k != j:
#                         cnt += 6
#                     else:
#                         cnt += 3
#
#     ans.append(cnt)
# print(ans)
ans = [0] * (n+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            cal = i**2+j**2+k**2+i*j+j*k+k*i
            if cal <= n:
                ans[cal] += 1
print(*ans)

Submission status: Wrong Answer

Solution code:
'''     J A I ~ S H R E E ~ R A M     '''

# Title: aising2020_c.py
# dated: 11-07-2020 17:43:44
# Creator & Template by : Udit Gupta @luctivud


import math; from collections import *
import sys; from functools import reduce

# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

DIRECTIONS = [[0, 1], [0, -1], [1, 0], [1, -1]] #up, down, right, left
NEIGHBOURS = [(i, j) for i in range(-1, 2) for j in range(-1, 2) if (i!=0 or j!=0)]

OrdUnicode_a = ord('a'); OrdUnicode_A = ord('A')
CAPS_ALPHABETS = {chr(i+OrdUnicode_A) : i for i in range(26)}
SMOL_ALPHABETS = {chr(i+OrdUnicode_a) : i for i in range(26)}

MOD_JOHAN = int(1e9)+7; MOD_LIGHT = 998244353; INFINITY = float('inf')
MAXN_EYEPATCH = int(1e5)+1; MAXN_FULLMETAL = 501

# sys.stdin=open("input.txt","r");sys.stdout=open("output.txt","w")

# for _testcases_ in range(int(input())): 
n = int(input())
ans = [0] * (n+1)
i = 1
while i * i * i < n:
    i += 1
n0001 = i+1
for i in range(1, n0001):
    for j in range(1, n0001):
        for k in range(1, n0001):
            e = (i**2) + (j**2) + (i*j) + (k**2) + (j*k) + (i*k)
            if e <= n:
                # print(i, j, k, e)
                ans[e] += 1

print(*ans[1:], sep="\n")




'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
'''

Submission status: Wrong Answer

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):
  for y in range(1,x+1):
    for z in range(1,y+1):
      k=3
      if x==y and 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: Wrong Answer

Solution code:
from itertools import product

N = int(input())

cnt = [0]*100000000

for x in range(1,81):
    for y in range(1,81):
        for z in range(1,81):
            cnt[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1

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