Naughty Sid and SEV-Hackerearth
C Solution
#include <stdio.h>
#include<math.h>
#define PI 3.14159265
int main()
{
long long int t,i,a,H,o,h;
scanf("%lld",&t);
float x,y;
for(i=0;i<t;i++)
{
scanf("%lld %lld %lld",&a,&H,&o);
x=(1.0*H)/a;
y=tan(o*PI/180.0);
if(x>y)
{
h=ceil(H-(a*y)/2);
}
else
{
h=ceil((H*H)/(2*a*y));
}
printf("%lld\n",h);
}
return 0;
}
To try this on Hackerearth
For more Hackerearth Problems
#include <stdio.h>
#include<math.h>
#define PI 3.14159265
int main()
{
long long int t,i,a,H,o,h;
scanf("%lld",&t);
float x,y;
for(i=0;i<t;i++)
{
scanf("%lld %lld %lld",&a,&H,&o);
x=(1.0*H)/a;
y=tan(o*PI/180.0);
if(x>y)
{
h=ceil(H-(a*y)/2);
}
else
{
h=ceil((H*H)/(2*a*y));
}
printf("%lld\n",h);
}
return 0;
}
To try this on Hackerearth
For more Hackerearth Problems
Comments
Post a Comment