Waclaw was playing with red and blue points, and he has come up with a very peculiar way…
- User
Waclaw was playing with red and blue points, and he has come up with a very peculiar way of building triangles made up of points. The whole process is incremental, and done in steps.
At step 1, Waclaw builds a triangle made up of 3 3 red points. We define the size of the triangle as being the number of points on each side, so in the case of this triangle the size is equal to 2 2. The next steps follow an inductive principle. At step 𝑁 + 1 N+1, Waclaw starts off with a triangle from step 𝑁 N having size 𝐿 L, adds to the bottom of it an inverted triangle of size 𝐿 + 1 L+1 consisting of blue points, and then makes two other copies of the triangle from step 𝑁 N and adds them to the left and right of the inverted blue triangle.
Step 2 results in building a triangle of size 5
Step 3 results in building a triangle of size 11
Waclaw has come up with a way to identify points using two coordinates ( 𝑥 , 𝑦 ) (x,y), corresponding to the 𝑦 y-th point (from left to right) on the 𝑥 x-th line (from top to bottom). You need to answer 𝑄 Q queries of the type:
Give a pair of coordinates ( 𝑥 , 𝑦 ) (x,y), find the color of the point at those coordinates. Standard input The first line contains a single integer 𝑄 Q.
Each of the next 𝑄 Q line contains a single integer 𝑁 N corresponding to a query.
Standard output For each of the 𝑄 Q queries print the answer on a line: 1 1 if the point is red, 0 0 if it's blue.
Constraints and notes 1 ≤ 𝑄 ≤ 1 0 5 1≤Q≤10 5
1 ≤ 𝑦 ≤ 𝑥 ≤ 1 0 9 1≤y≤x≤10 9
Waclaw builds a triangle of step 30 30, so it's guaranteed all the points from the input exist. Input Output 6 1 1 5 3 8 2 8 6 5 4 6 4 1 0 1 0 1 0
solve this
- Assistant