chef and polygon cakes why this code giving wrong answer

#include<stdio.h>
int main()
{
int t,n,a,k,d,s;
scanf("%d",&t);
while(t–){
scanf("%d %d %d",&n,&a,&k);
d=(((n-2)360)/(n(n-1)))-(2*a/(n-1));
s=a+(k-1)*d;
printf("%d 1",s);
}
}

Your code can be displayed much more nicely, including showing the characters that are misinterpreted as format commands above, by highlighting it in the editor and pressing the code format button in the editor toolbar:

alt text

This indents the whole block to allow interpretation as literal text, including preserving code indents.

You could also link to the code, as there for example using [link to](https://www.codechef.com/viewsolution/19812132).

On the actual coding issue, you should re-read the output requirements. The request is for the numerator and denominator of a fraction that evaluates exactly to the angle in question, which may be non-integer. If the request had been for the angle directly to some precision, you should have had d and s as floats etc…

1 Like