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:
import sys
import math
import statistics
import itertools
from collections import deque
N=int(input())

ans_lis =[0]*10000000


nn=math.sqrt(N)
n=int(nn)
#per_lis=itertools.permutations(list(range(1,4)))
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            tmp=0
            tmp=i**2+j**2+k**2+i*j+j*k+k*i
            ans_lis[tmp-1]+=1
for g in range(n):
    print(ans_lis[g])

Submission status: Wrong Answer

Solution code:
import math

n = int(input())

for i in range(1, n+1, 1):
    maxn = math.ceil(i**0.5)
    cnt = 0
    flag = False

    for x in range(1, maxn+1):
        if x**2 > i:
            break
        
        for y in range(x, maxn+1):
            if x**2 + y**2 + x* y > i:
                break
            else:
                tmp = x**2 + y**2 + x*y - i
                z = (-(x + y) + ((x+y)**2 - 4 * tmp)**0.5) / 2
                zmin = max(math.ceil(z)-1, y)
                zmax = math.floor(z)+1
                if zmax < y:
                    break
                for z in range(zmin, zmax+1):
                    if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                        if x == y and y == z :
                            cnt += 1
                        elif x != y and y != z:
                            cnt += 6
                        else:
                            cnt += 3
                    elif x**2 + y**2 + z**2 + x*y + y*z + z*x > i:
                        break
            
    print(i, cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for i in range(0, n, 1):
    s = 0
    for x in range(1, n, 1):
        if x**2 + 2*x + 3 > i+1:
            print(s)
            break
        else:
            for y in range(1, x+1, 1):
                for z in range(1, y+1, 1):
                    if f(x,y,z) == i+1:
                        if x == y and y == z:
                            s += 1
                        elif x == y or y == z:
                            s += 3
                        else:
                            s += 6

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())

    f = [0] * (N+1)

    for x in range(1, 41):
        for y in range(x, 42):
            for z in range(y, 42):
                if (ans := (x+y+z)**2 - x*y - y*z - z*x) in range(1, N+1):
                    count = 0
                    if x == y and y == z:
                        count = 1
                    elif x != y and y != z and z != x:
                        count = 6
                    else:
                        count = 3
                    f[ans] += count
    
    for i in range(1, N+1):
        print(i, f[i])




def input_ints():
    line_list = input().split()

    if len(line_list) == 1:
        return int(line_list[0])
    else:
        return map(int, line_list)


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


def input_int_tuple_list(n: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
def f(i):
  co=0
  for z in range(1,10):
    if 4+z**2+z+z>i:
          break
    for y in range(1,10):
      if y**2+z**2+z*y+z+y+2>i:
          break
      for x in range(1,10):
        if x**2+y**2+z**2+z*y+z*x+y*x==i:
          co+=1
        if x**2+y**2+z**2+z*y+z*x+y*x>i:
          break
  return co
for i in range(1,n+1):
  print(f(i))

Submission status: Wrong Answer

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
def main():

    n = input_int()
    ans = collections.defaultdict(set)

    for x in range(1, 99):
        for y in range(1, 99):
            for z in range(1, 99):
                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: Wrong Answer

Solution code:
N = int(input())
ans1 = [0] * N
ans2 = [0] * N
ans3 = [0] * N

for x in range(1,101):
    for y in range(1,71):
        for z in range(1,58):
            if (x**2+y**2+z**2+x*y+y*z+z*x) <= N:
#                n = int(0.5*((x+y)**2+(y+z)**2+(z+x)**2))
                n = x**2+y**2+z**2+x*y+y*z+z*x
                if x == y and y == z and z == x:
                    ans1[n-1] = 1
                elif x == y or y == z or z == x:
                    ans2[n-1] = 3
                elif x != y and y != z and z != x:
                    ans3[n-1] = 6
for x,y,z in zip(ans1, ans2, ans3):
    print(x+y+z)

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,101):
    for y in range(x,101):
      for z in range(y,101):
        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:
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


def solve(n):
    result = [0] * n
    for i in range(1, n+1):
        i2 = pow(i, 2)
        for j in range(i, n+1):
            j2 = pow(j, 2)
            for k in range(j, n+1):
                k2 = pow(k, 2)
                curr = i2 + j2 + k2 + i*j + i*k + j*k
                if curr > n:
                    break
                count = 6
                if i == j and i == k:
                    count = 1
                elif i == j or i == k:
                    count = 3
                result[curr-1] += count
    return result


if __name__ == "__main__":
    n = int_in()
    result = solve(n)
    for item in result:
        out(item)

Submission status: Wrong Answer

Solution code:
def main():
        
    import math

    N = int(input())

    for n in range(1, N + 1):
        max_itr = min(40, int(math.sqrt(n)) + 1)
        
        ans_list = []
        ans = 0
        
        for x in range(1, max_itr):
            # for y in range(1, x+1):
            for y in range(1, max_itr):

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

                    left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                    if (left_eq == n):
                        ans_list = [x, y, z]
                        ans_len = len(set(ans_list))
                        


                        ans += 1
                        
                        # if (ans_len==3):
                        #     ans += 6
                        # elif (ans_len == 2):
                        #     ans += 3
                        # else:
                        #     ans += 1

        
        
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
n = [0 for _ in range(N)]

def cob(m):
    if m <= 0:
        return m
    return m + cob(m-1)

# x > y > z
test = 0
for x in range(1,N+1):
    if test > 100:
        break
    for y in range(1,x+1):
        if test > 100:
            break
        for z in range(1,y+1):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if len(set([x,y,z])) == 3:
                cnt = 6
            elif len(set([x,y,z])) == 2:
                cnt = 3
            else:
                cnt = 1
            if ans > N:
                test += 1
                break
            n[ans-1] += cnt

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [0] * (N + 1)
for i in range(1,101):
    for j in range(1,101):
        if i ** 2 + j ** 2 > N: break
        for k in range(1,101):
            if i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i <= N:
                ans[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i] += 1
for i in ans: print(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 we==2:
    sm+=1
    a=1
  else:
    a+=1
  if brk>n and a>=sm-2:
    break
#print(d)
l=[0]*n
ll.sort()
for i in ll:
  if i-1>n:
    break
  else:
    l[i-1]=d[i]
#print(ll)
for i in l:
  print(i)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
f = [0] * n
sqrt_n = int(math.sqrt(n/6)) +1
for i in range(n) :
    for x in range(1,sqrt_n) :
        for y in range(1,sqrt_n) :
            for z in range(1,sqrt_n) :
                if x*x+y*y+z*z+x*y+y*z+z*x == i+1 :
                    f[i] += 1
for _ in range(n) :
    print(f[_])

Submission status: Wrong Answer

Solution code:
def main():
        
    import math

    N = int(input())

    for n in range(1, N + 1):
        max_itr = min(38, int(math.sqrt(n)) + 1)
        
        ans_list = []
        ans = 0
        
        for x in range(1, max_itr):
            # for y in range(1, x+1):
            for y in range(1, max_itr):

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

                    left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                    if (left_eq == n):
                        ans_list = [x, y, z]
                        ans_len = len(set(ans_list))
                        


                        ans += 1
                        
                        # if (ans_len==3):
                        #     ans += 6
                        # elif (ans_len == 2):
                        #     ans += 3
                        # else:
                        #     ans += 1

        
        
        print(ans)


if __name__ == '__main__':
    main()

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*i + j*j + k*k + i*j + j*k + k*i)
            if n < (N+1):
                o[n] += 1
            if n > 1001:
                break

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