Poj Solution 2463

http://poj.org/problem?id=2463

#include<iostream>
#include"math.h"
using namespace std;

double k,l,s,w;
const double g=9.81;

bool init()
{
    cin>>k>>l>>s>>w;
    return !(k==0&&l==0&&s==0&&w==0);
}
int calculate()
{
    double v,v0,h,vv;
    if(s<=l||k==0)
    {
        v=sqrt(2*s*g);
        
        if(v>10)return -1;
        else return 1;
    }
    else
    {
        v0=sqrt(2*l*g);
        h=(2*w*g+sqrt(4*w*w*g*g+8*k*w*g*l))/(2*k);
        h+=l;
        
        if(h<s)return 0;
        vv=(2*w*g*s-k*(s-l)*(s-l))/w;

        if(vv<0)while(1)cout<<"faint"<<endl;
        v=sqrt(vv);
        if(v>10)return -1;
        else return 1;
    }
}
int main()
{
    while(init())
    {
        switch(calculate())
        {
        case 1:cout<<"James Bond survives."<<endl;break;
        case 0:cout<<"Stuck in the air."<<endl;break;
        case -1:cout<<"Killed by the impact."<<endl;break;
        }
    }
    return 0;
}
        
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *