A Pizza Slice

Pages: 12
ChefX showed ChefY his new pizza slice design. The design is a planar figure that can be drawn in the following way:

Draw a point A0 and two rays from this point such that the angle between them is α<π/2.
Mark N points A1,A2,A3,…,AN on one ray in this order (A1 is closest to A0).
Mark N points B1,B2,B3,…,BN on the other ray in this order (B1 is closest to A0).
For each valid i, draw a line segment between points Ai and Bi+1.
For each valid i, draw a line segment between points Bi and Ai+1.
Finally, draw a line segment between points AN and BN.
All these 2N−1 line segments must have equal lengths, which must also be equal to |A0A1|=|A0B1|.
The result should look roughly like this:

ChefY wants to show ChefX that he does not know his own design very well. He asks ChefX to compute the angle between three of the marked points in this figure. It is clear that there are only four types of angles:

Can you help ChefX find the angle ChefY asks for? It can be proved that under the given constraints, each angle can be written as π⋅m/n, where m and n are coprime integers; you should find m and n.

Example Input
175456798 1 151163203 151163204 151163205
Example Output
66583464 116971199
Example case 1: The type is 1, so the angle we want is A151163203A151163204B151163205. The angle is (66583464/116971199)π≐1.7883.

Problem Link : https://www.codechef.com/JAN19A/problems/XYPIZQ
Last edited on
My approach is :
First, calculate the angle made by two rays by using the given value of N . I think the angles are following some pattern and the base angle of that pattern is given by angle made by two rays.

Is my approach is in the right direction ??

Last edited on
but i stuck to find out angle between two rays.
how to find alpha i.e.,the first angle
Explanation of the given test case contains the whole solution.
Just use your brains.
It is pure geometry.
And to thos who have done these problems, it is a kind request please stop assisting these cheaters. If u are stuck somewhere then u can get help bit u just cannot expect someone to tell u the whole logic for a problem.
If u want to learn then just apply your brains and see explanation from codechef after the contest is over.
I agree with @blackmamba.
I have solved it and it is just an observation based question(geometry).
But I am getting wrong answer, if somebody have solved it can provide any test cases please.

please tell me the solution of this:-
1000000000 1 999999998 999999999 1000000000
1000000000 1 100000000 100000001 100000002
1000000000 1 199999998 199999999 200000000
1000000000 1 100000000 100000001 100000002
Last edited on
Are the points equidistant?
@honeybuzz constratints for points are given in the problem
@lazybot i solved the question and supplying the inputs this is my answer
1000000001 2000000001
633333333 666666667
1800000001 2000000001
633333333 666666667

PS:i dont understand why this answer is reported this is just a help Im not providing the code or something common!
Last edited on


Please mail me the answer to this solution or I am gonna lose bet I made with my friend. Thing is I was supposedly good at DSA but am ridiculous in geometry, and that is the thing I hate about these long challenges. Please help
i am getting a wrong answer eve after solving it ? are there any trick or base cases i cant get through?
Post your solution here, will compare it and tell. Also are you getting it right for the given cases in the ques description?
@blackmamba what I meant was that is A1A2 = A2A3 = B1B2 = B2B3 and so on...
honeybuzz wrote:
Is A1A2 = A2A3 = B1B2 = B2B3 and so on...

Not according to the problem description. Some of those may be equal length as a consequence of the given parameters, but they are not defined to be.
No base cases are there test cases arent that tricky just build the sequence and the notice the pattern.
Btw can any body give me hint for EARTHSEQ?i can onl solve the subtask.
yeah it would be good if someone gives hint for EARTSEQ I dont have any idea on how to start And for the solution of this question is pretty much straight forward just build the sequence as said above and notice the pattern
Explaining further find angle alpha for each case that is when n=1,n=2,n=3 u will notice a pattern there and find the type1 type2 type3 type4 angles they will again have a relationship with angle alpha and follow a pattern.
Try again this is just basic geometry give it a try it is a cakewalk trust me.
@LordRiddle what do you mean by "sequence" and "alpha" here?
Is alpha=180/7 and for AAB x=0;y=1;z=2 180-2(alpha)
But after some time the angle becomes negative how to correct that or am i going the correct way
Please reply someone
Pages: 12