Monday, May 30, 2016

URI Online Judge Solution 1039 || Fire Flowers

URI Online Judge | 1039

Fire Flowers

By Márcio Oshiro  Brazil
Timelimit: 1
Nowadays a fire flower isn’t a thing considered strange for 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 his enemies.
However, it was already said about fire flowers a 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 her directly. Who got such flower possessed the ability to read the other people's minds, 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: R(1 ≤ R1) , X1(|X1|), Y1(|Y1|), R(R≤ 1000), X2(|X2|), Y2 (Y≤ 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.
Input SampleOutput Sample
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

URI Online Judge Solution 1039 || Fire Flowers in C++


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


See in Dropbox code
See URI Question link

I've done 1039 in URI in C language also but there I've got a TIME LIMIT EXIST error. The code was same as the previous time in C language. But the error will occur. Obviously C++ is more faster than C language. So, try your programming in C++. The URI 1039 || Fire Flowers is a simple problem of Geometry.I think the logic on URI 1039 || Fire Flowers  is clear to you. For not clear, comment here. I'll try to help you.

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.