Friday 16 September 2016

Solution of URI 2203 :: Crowstorm


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()
{
    double x1, y1, x2, y2, v, r1, r2, X, Y, dstnce, range;
    while(scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) != EOF)
    {
        scanf("%lf%lf%lf", &v, &r1, &r2);
        X = (x2-x1)*(x2-x1);
        Y = (y2-y1)*(y2-y1);
        dstnce = sqrt(X+Y);
        dstnce += v*1.50;
        range = r1+r2;
        if(dstnce > range) printf("N\n");
        else printf("Y\n");
    }
    return 0;
}

5 comments:

  1. vaiya wrong ans dekhasse evabe korle.

    ReplyDelete
    Replies
    1. আমি আবার রিসাবমিট করছি।
      একসেপ্ট হইছেতো।

      Delete
  2. As-Salaam Alaikum,

    Can you please explain these 2 lines?

    dstnce += v*1.50;
    range = r1+r2;

    Thank you.

    ReplyDelete
    Replies
    1. X = (x2-x1)*(x2-x1);
      Y = (y2-y1)*(y2-y1);
      dstnce = sqrt(X+Y);
      the part above calculates the distance between Fiddlestick and ivasor(considering Fiddlestik and Ivasor are stand still).
      but ivasor can move and it moves opposite to Fiddlestick in a constant valocity and Fiddlesticks Crowstorm happens after 1.5 second. As Ivasor can move we have to calculate the total distance of Ivasor (including Ivasors moving distance within this 1.5 second) which is
      v * 1.5(S = v * t).[moving distance]
      Now,
      total distance : dstnce += v * 1.5(Initial/distance while both standing + distance while moving).

      Now, Fiddlestick attacks by moving distance r1 and after reaching r1 Fiddlestick creats a ring of crows within r2 radius. So, Fiddlestick first moves from initial point to r1 then attacks within the range r2.So,
      Total range = r1 + r2.(initial point to r1(move) + r1 to r2(attack)) .
      Thats why,
      range = r1 + r2;

      Please ignore the mistakes.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete

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