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())
lst=[0]*10100
for i in range(1, 41):
  for j in range(1, i+1):
    for k in range(1, j+1):
      temp=i**2+j**2+k**2+i*j+j*k+k*i
      if i==j and j==k:
        lst[temp+1]+=1
      elif i==j and j!=k:
         lst[temp+1]+=3
      elif j==k and k!=i:
         lst[temp+1]+=3
      elif k==i and i!=j:
         lst[temp+1]+=3
      elif i!=j and j!=k and k!=i:
         lst[temp+1]+=6
for p in range(1, n+1):
  print(lst[p+1])

Submission status: Wrong Answer

Solution code:
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

N = int(input())
for i in range(1, N+1):
    if i < 6:
        print(0)
        continue
    cnt = 0
    for x in range(1, 10):
        for y in range(1, 10):
             D = (((x+y)**2 - 4*(x**2+y**2+x*y-i)) ** (1/2))
             if ((x+y)**2 - 4*(x**2+y**2+x*y-i)) > 0 :
                 Z = (-(x+y) + D) / 2
                 if is_integer(Z) and Z>0:
                     cnt += 1
    print(cnt)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from sys import maxsize


def two_div(l):
    divs = []
    if l == 2:
        return [(1,1)]
    if l == 3:
        return [(2,1)]
    preL = 0
    for m in range(l-1,l//2 -1,-1):
        if preL == l-m:
            break
        divs.append((m,l-m))
        preL = m
    return divs


def three_div(mmm):
    if mmm == 3:
        return[(1,1,1)]
    if mmm == 4:
        return[(2,1,1)]
    divs = []
    rest = 1
    for m in range(mmm-2,mmm//3 -1,-1):
        rest += 1
        two_c = two_div(rest)
        for t in two_c:
            if m < t[0]:
                continue
            c = (m,t[0],t[1])
            divs.append(c)
    return divs

def triple(x,y,z):
    v = x*x + y*y + z*z + x*y + y*z + z*x
    return v

def main():
    n = int(input())
    ans = [0] * (n+1)
    for goukei in range(3,100):
        mini = maxsize
        factors = three_div(goukei)
        # print("================")
        for x,y,z in factors:
            # print(x,y,z)
            v = triple(x,y,z)
            # print("=>"+str(v))

            if x == y and y == z and v <= n:
                ans[v] += 1
            elif x!=y and y!=z and z!=x and v <= n:
                ans[v] += 6  
            elif v <= n:
                ans[v] += 3

            if mini > v:
                mini = v
        if mini >= n:
            break

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
def search(n):
    for x in range(1, int(math.sqrt(n)) + 1):
        xx = x*x
        if n - xx <= 0:
            return None
        for y in range(1, int(math.sqrt(n)) + 1):
            yy = y*y
            xy = x*y
            if n - xx - yy - xy <= 0:
                break
            z = binarySearch(n, x, y, xx + yy + xy)
            if z:
                return (x, y, z)


def binarySearch(n, x, y, t):
    global N
    right = -1
    left = N + 1
    while(abs(right - left) > 1):
        z = left + (right - left) // 2
        l = t + z*z + y*z + z*x
        if l == n:
            return z
        elif l < n:
            right = z
        else:
            left = z
        # print(right, left, z)
    return None

ans = list()
for n in range(1, N+1):
    xyz = search(n)
    if xyz == None:
        ans.append("0")
        continue
    t = len(set(xyz))
    if t == 1:
        ans.append("1")
    elif t == 2:
        ans.append("3")
    else:
        ans.append("6")

print("\n".join(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
la=list(range(2,10**2+1))
l=[]
for i in range(len(la)):
  l.append(la[i]**2)
for n in range(1,N+1):
  if n<6:
    print(0)
  else:
    c=0
    for x in range(len(l)):
      if l[x]*3>2*n:
        break
      else:
        for y in range(x,len(l)):
          if l[x]+2*l[y]>2*n:
            break
          else:
            for z in range(y,x+y+2):
              if x+y+2>len(l):
                break
              if l[x]+l[y]+l[z]>2*n:
                break
              else:
                
                if l[x]+l[y]+l[z]==2*n:
                  
                  if (x+y+z)%2==0: 
                      if l[x]==l[y] and l[y]==l[z]:
                        c+=1
                      elif l[x]==l[y] or l[y]==l[z]:
                        c+=3
                      else:
                        c+=6
                   
    print(c)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
n_2 = math.floor((n)**(1/2))
cnt = 0
for n in range(1,n+1):
  cnt = 0
  for x in range(1,n_2 +1):
    for y in range(1, n_2 +1-x):
      for z in range(1, n_2 +1-y-x):
        if x+y+z == ((n + x*y + y*z + z*x)**(1/2)):
          cnt +=1
  print(cnt*3)

Submission status: Wrong Answer

Solution code:
def  XYZTriplets():

    num = int(input())
    
    for i in range(1, num+1):
        count = 0

        x = 1
        y = 1
        z = 1

        for x in range(1, int(pow(num, 1./3.)) ):
            for y in range(1, int(pow(num, 1./3.)) ):
                for z in range(1, int(pow(num, 1./3.)) ):
            
                    function = 0.5*( (x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x) ) - i
                                
                    if function == 0:
                        count = count + 1
                        
                    
        print(count)
        

if __name__ == '__main__':
    XYZTriplets()

Submission status: Wrong Answer

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

for n in range(1, N+1):
    count = 0
    for x in range(1, int(sqrt(n) / 3)):
        for y in range(x,int(sqrt(n) * 2 / 3)):
            for z in range(y, int(sqrt(n))):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == n:
                    if len(set([x, y, z])) == 3:
                        count += 6
                    elif len(set([x, y, z])) == 2:
                        count += 3
                    elif len(set([x, y, z])) == 1:
                        count += 1
    print(count)