Saturday 9 January 2016

Solution of LIGHT OJ 1311 :: Unlucky Bird


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int tst, i;
    double v1, v2, v3, a1, a2, t, t1, t2, fly, d1, d2;
    scanf("%d", &tst);
    for(i=1; i<=tst; i++)
    {
        scanf("%lf%lf%lf%lf%lf", &v1, &v2, &v3, &a1, &a2);
        t1 = v1/a1;
        t2 = v2/a2;
        t = t1;
        if(t2>t1) t = t2;
        d1 = (v1*v1)/(2*a1);
        d2 = (v2*v2)/(2*a2);
        fly = t*v3;
        printf("Case %d: %lf %lf\n", i, d1+d2, fly);
    }
    return 0;
}

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.