Problem Description
Come back school from the 33rdACM / ICPC Asia ChenDu, everyone is exhausted, in particular the captain Wiskey. As saying that night, Wiskey drink a lot of wine, just as he blurred, fall to sleep. All of a sudden, Wiskey felt a slight discomfort in the chest, and then vomiting, vomitted all over. The next day, Wiskey is extremely sluggish, vomit still on the train.
Your task is to calculate the coordinates of vomit.
We assume that the quality of vomit is m, and its size can be ignored.
As the figure below:
The vomit start from the blue point A, whose speed is V, and its angle with X-axis is a. If the vomit hit the ceiling, then its value of the speed don't changed and if before the collision the angle of the speed with X-axis is b, then after the collision the angle of the speed with X-axis is b , too.
Ignore air resistance, acceleration due to gravity g = 9.87m/s2, calculate and output Q.
(you can assume that the vomit will not fall to the higher berth)
Input
Each line will contain three numbers V , m and a (0 <= a < 90)described above.
Process to end of file.
Output
For each case, output Q in one line, accurate up to 3 decimal places.
Sample Input
100 100 45
Sample Output
3.992
Come back school from the 33rdACM / ICPC Asia ChenDu, everyone is exhausted, in particular the captain Wiskey. As saying that night, Wiskey drink a lot of wine, just as he blurred, fall to sleep. All of a sudden, Wiskey felt a slight discomfort in the chest, and then vomiting, vomitted all over. The next day, Wiskey is extremely sluggish, vomit still on the train.
Your task is to calculate the coordinates of vomit.
We assume that the quality of vomit is m, and its size can be ignored.
As the figure below:
The vomit start from the blue point A, whose speed is V, and its angle with X-axis is a. If the vomit hit the ceiling, then its value of the speed don't changed and if before the collision the angle of the speed with X-axis is b, then after the collision the angle of the speed with X-axis is b , too.
Ignore air resistance, acceleration due to gravity g = 9.87m/s2, calculate and output Q.
(you can assume that the vomit will not fall to the higher berth)
Input
Each line will contain three numbers V , m and a (0 <= a < 90)described above.
Process to end of file.
Output
For each case, output Q in one line, accurate up to 3 decimal places.
Sample Input
100 100 45
Sample Output
3.992
#include <iostream>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
double v,m,a;
double t;
double g=9.87;
while(cin>>v>>m>>a)
{
double vx=cos(a*3.1415926/180)*v;
double vy=sin(a*3.1415926/180)*v;
if(vy*vy/(2*g)>0.5)
{
double t1=2*(vy-sqrt(vy*vy-2*0.5*g))/g;
double t2=(sqrt(vy*vy+2*g*3)-vy)/g;
t=t1+t2;
}
else
{
t=2*vy/g+(sqrt(vy*vy+2*g*3)-vy)/g;
}
cout<<fixed<<setprecision(3)<<vx*t<<endl;
}
return 0;
}