 # Atcoder C-XYZ Triplets problem

How to solve this question?

1 Like

Just apply Brute Force

But how

Wait

Ok

Maximum value of any variable (x,y,z) can be ~100. So, you can do something like this-

Code
``````'''Author- Akshit Monga'''
list=[0 for i in range(10**4+1)]
for x in range(1,100):
for y in range(1,100):
for z in range(1,100):
var=x**2 +y**2 +z**2 +x*y +y*z +z*x
if var<=10**4:
list[var]+=1

n=int(input())
for i in range(1,n+1):
print(list[i])
``````

x , y , z will always be <=100

or else, x^2 or y^2 or z^2 > 10^4

Thanx

To find the maximum value-
put y=z=1
x^2+2x + 3= 10^4
x will be ~100.

1 Like

Won’t it show TLE… 3 nested loops??

100 * 100 * 100 = 106 , will be okay for 1 testcase.

1 Like

If there were multiple test cases then also It is fine. That part is just pre-calculation.

1 Like

I also edited this in my comment but what if queries will be upto 104 and each time N = 104

1 Like

It is border case. Might work upto T=10^3. Will work for sure if T=10^2.

1 Like

Yeah, that’s will be okay.

1 Like

What are queries? You’re already asked for all of the values f(1)...f(n)

1 Like

Yeah, for this question there is only 1 testcase, but In case we have to calculate f(1), f(2)…f(n) for more than 1 testcase i.e. T=104 then it will give TLE.

Please tell me when I reply to someone, why it doesn’t show a reply icon on top right.

Do you mean outputting 10^8 numbers?

It doesn’t show a reply icon if the person you replied to is directly above you.

1 Like

I didn’t notice that. 