 # august cook-off 1st and 2nd question

The first two questions were a bit of cake-walk , but i found out many people had wrong submissions on the second question.
well the common observation that missed in the first question was the elevator started from the ground to top and then back to ground, hence taking twice of time . so simple time=distance/velocity will suffice here. here is the solution link http://ide.geeksforgeeks.org/sPhhTt

Moreover in the second question, it was a simple maths problem ,where you can simple check if |b-a|==n/2 (IF N IS EVEN)then it lies on the diameter ,hence the answer will be always 0, read in lower classes that any triangle drawn with diameter as the base will be 90 at the circumference. BUT many people thot that A<B and the most common part that was missed was that if k is ODD it will have no diameters.

if the points do not form a diameter then , for example if i take k as 11 and A as 2 and B as 7 then there are two parts one which has(3,4,5,6) and the other has (8,9,10,11,1) hence the part with the lower value will be your answer since the part with higher values will form acute angles (basic maths).
Some basic maths will get you the formulae.
here is the solution link https://www.codechef.com/viewsolution/15058202

i hope this helps the people(beginners) who have just started coding.

5 Likes

Change the title to Q1 and Q2 Explanation.

Can you tell me what is the problem with this code for the 2nd one???

``````#include <stdio.h>

long long int findObtuse(long long int k,long long int A,long long int B)
{
long long int predcount=0,t;
long double primAngle = 360.000000000/((long double)k);
if(A>B)
{
t = A;
A = B;
B = t;
}

long double angleDiff = (B-A)*primAngle;
if(angleDiff >= 180.000000000)
{

predcount = (k-B)+(A-1);
if(angleDiff/2.0>90.000000000)
return predcount;
else
return 0;

}
else
{
angleDiff = 360.000000000 - angleDiff;
predcount = B-A-1;
if(angleDiff/2.0>90.000000000)
return predcount;
else
return 0;
}
}
int main()
{
long long int T,k,A,B;
scanf("%lld",&T);

while(T)
{
scanf("%lld %lld %lld",&k,&A,&B);
printf("%lld\n",findObtuse(k,A,B));
T--;
}

return 0;
}``````

It is definitely a great observation from your end. Even I committed the same mistake of not observing that AB cannot form a diameter when k is ODD while solving the second question which led to ample wrong submissions from my end before eventually succeeding. This post is definitely beneficial for newbies who have just started coding and the ones who failed to answer this questions correctly.I guess this might benefit them by learning from such mistakes and cover all bases while solving a problem.

yes bro done @abdullah768

it is getting precision values since you are using double

can you explain more ,facing toughness to code

I understood it finally //