Algorithm


Problem Name: beecrowd | 2203

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2203

Crowstorm

 

By Ícaro Dantas, UFCG BR Brazil

Timelimit: 1

Fiddlesticks is a champion of League of Legends, he has as his ultimate ability "CrowStorm", it works as follows:

First Fiddlesticks chooses a strategic location and promptly he prepares to resurface in one direction within a certain distance, then it is rooted and channels the ultimate by just 1.5 seconds, after that time it resurfaces immediately at the target site with a flock of crows flying in the around and causing much damage.

Fiddlesticks want your help to find out if in a certain position it is possible to achieve an invader with his ultimate skill.

Note: Consider that Fiddlesticks always uses his ultimate exactly in the direction of ivasor and the invader always tries to flee in the opposite direction to Fiddlesticks, at a constant speed.

 

Input

 

The entry consists of several lines, each line contains the following integer values: Xf, Yf, Xi, Yi, Vi, R1 e R2(0 ≤ Xf, Yf, Xi, Yi, Vi, R1 e R2 ≤ 100), representing respectively the coordinates of Fiddlesticks, the initial coordinates of the invader, the speed of the invader, the ultimate of casting radius and flight radius of crows. Consider the unit of measurement as the meter.

 

Output

 

In the output you should print for each line the 'Y' character if it is possible to achieve the invasor or 'N' otherwise, both followed by a line break.

 

 

 

Input Sample Output Sample

4 6 22 6 0 16 2

4 6 22 6 1 16 2

 

Y

N

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream&t;
#include <cmath>

using namespace std;

int main()
{
    double x1, x2, y1, y2, v, r1, r2, a, b, c, ans;

    while (cin >> x1 >> y1 >> x2 >> y2 >> v >> r1 >> r2)
    {
        a=pow((x2-x1), 2);
        b=pow((y2-y1), 2);
        c=sqrt(a+b);

        if (((r1+r2)>=(c+(1.5*v))))
            cout << "Y" << endl;
        else
            cout << "N" << endl;
    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4 6 22 6 0 16 2 4 6 22 6 1 16 2

Output

x
+
cmd
Y N

#2 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var prompt = function(texto) { return lines.shift();};
while (true) {
  var input = prompt().split("");
  if (isNaN(input[0])) {
    break;
  }
  input = input.join("");

  var [x1, y1, x2, y2, V, R1, R2] = input.split(" ").map(Number);

  var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
  distance = distance + 1.5 * V;
  distance = distance - R1;

  if (distance  < = R2) {
    console.log("Y");
  } else {
    console.log("N");
  }
}

Copy The Code & Try With Live Editor

Input

x
+
cmd
4 6 22 6 0 16 2 4 6 22 6 1 16 2

Output

x
+
cmd
Y N
Advertisements

Demonstration


Previous
#2191 Beecrowd Online Judge Solution 2191 Goal Difference Solution in C, C++, Java, Js and Python
Next
#2217 Beecrowd Online Judge Solution 2217 Nove Solution in C, C++, Java, Js and Python