NECSTASY - Ecstasy

Can you please help me with this easy problem:

Here is my approach…

#include <bits/stdc++.h>
using namespace std;

int main()
{
long double d,x,y,tha,tmp,pi=acos(-1);
while(cin>>d>>x>>y)
{
cin>>tha;

    tha=(pi*(180.0-tha))/360.0; //operating in radians
    
    tmp=cos(tha);
    tmp=(d-y)/tmp;
    tmp+=x;
    
    printf("%.2Lf\n",tmp);
}
return 0;

}

I have no idea why i am getting WA. :slightly_smiling_face:

2 Likes

Hello Tarun…

you have done a little mistake .You should use sin(tha) in place of cos(tha).
Here is link of of my accepted code.
accepted code

1 Like

Okay…so in the given problem, there are 2 right angled triangles formed.
One is above the rope, and second one is below the rope.

I used the triangle which is formed above the rope, for which i used sin(theta) giving me WA (I think it wrong because of greater precision error in finding the angle of upper triangle).

Thanks @shubham_9586 :raised_hands: