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 Online Compiler and IDE - GeeksforGeeks

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 CodeChef: Practical coding for everyone

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

5 Likes

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.

can you explain more ,facing toughness to code

Change the title to Q1 and Q2 Explanation.

yes bro :slight_smile:

done @abdullah768

it is getting precision values since you are using double

I understood it finally :slight_smile: