[URI Online Judge] – 1039 – Fire Flowers

Nowadays a fire flower isn’t a thing considered estrange to many young people. This is because a famous video game popularized this type of flower. In this game the protagonist gained superpowers by touching a fire flower, going to shoot small fireballs to defeat your enemies.

However, there was already talk about fire flowers long time ago. In Polish mythology, fire flowers are flowers of great mystical power guarded by evil spirits. She had this name because it was so bright that was impossible to look at it directly. Who got such flower possessed the ability to read the minds of other people, finding hidden treasures and repel all evil.

To get a fire flower, one person should look for it in a forest before midnight on the eve of Kupaly Noc. Exactly at midnight, she flourished. To harvest it would be necessary to draw a circle around her. It seems an easy task, however, the evil spirits that guard the flower of all try to distract anyone trying to pick the flower. If the person failed when trying to draw a circle around the flower, would have his life sacrificed.

Given two circles, one designed by an ambitious fire flowers hunter and another representing the area of the flower, your task is to determine if the hunter dies or becomes rich with his conquest.

Input

The input contains many instances and ends with end of file (EOF). Each instance consists in a line with six integers: R1 (1 ≤ R1) , X1(|X1|), Y1(|Y1|), R2 (R2 ≤ 1000), X2(|X2|), Y2 (Y2 ≤ 1000).

The circle drawn by the hunter has radius R1 and center (X1; Y1). The circle that represents the flower area have radius R2 e center (X2; Y2).

Output

For each test case we will have a line of output, containing “MORTO” (dead) or “RICO” (rich) if the hunt can pick the flower.

Sample Input Sample Output
6 -8 2 3 0 0
7 3 4 2 4 5
3 0 0 4 0 0
5 4 7 1 8 7
MORTO
RICO
MORTO
RICO

Solution:

#include <iostream>
#include <cmath>
using namespace std;
int main(){
 double r1, x1, y1, r2, x2, y2;
 double distance;
while (cin >> r1 >> x1 >> y1 >> r2 >> x2 >> y2){
 distance = sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
 if (r1 >= distance + r2) cout << "RICO" << endl;
 else cout << "MORTO" << endl;
 }
return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s