Algorithm


Problem Name: beecrowd | 2950

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

The Two Towers

 

By Samuel Eduardo da Silva, IFSULDEMINAS/UFF BR Brazil

Timelimit: 1

Saruman the White, a great wizard of Middle-earth, betrayed good manners and joined the evil lord, Sauron. Sauron commands the tower of Minas Morgul, which houses one of his most feared servants, the Witch King of Angmar, one of the Nazgul (former human kings who were corrupted by the powers of Sauron's rings). Saruman commands the tower of Orthanc, where he creates his servants Uruk-hai, orcs more terrible than the conventional ones. For communication, they use the spherical relics called Palantír, which are at the top of their towers.
Middle-earth advances more and more in technology, much driven by the wars that affect it daily. One of the problems that has hampered its population is the Magnetic Communication Interference (ICM). Researchers from Minas Tirith, the great citadel of Gondor, concluded that to calculate the ICM for Palantír's, it is enough to divide the distance between the two Palantír's by their sum of their diameter. Gandalf the Gray came to question this conclusion, claiming that it did not make much sense, but he himself concluded that making sense of things does not make sense.
Saruman and Sauron need a stable communication because they are afraid that Frodo and his friends can disrupt their plans, so they want to know how much ICM there is in the communication of their Palantír's, so that they know how much magic they must use in communication.

 

Input

 

The entry is composed of 3 integers, N(0 < N < 10000), X and Y(0 < X, Y < 100), which indicate, respectively, the distance between the Palantír, the diameter of the Palantír of Sauron and the diameter of the Palantír of Saruman.

 

Output

 

A double value indicating the ICM of the communication of the Palatír de Sauron and Saruman, to 2 decimal places.

 

 

 

Input Samples Output Samples

100 2 2

25.00

 

 

 

200 3 8

18.18

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main()
{
    float N;
    float X;
    float Y;

    scanf("%f %f %f", &N, &X, &Y);

    printf("%.2f\n", N/(X+Y));

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

Input

x
+
cmd
100 2 2

Output

x
+
cmd
25.00

#2 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("fs")
const [distanceBetweenPalantirs, diameterA, diameterB] = readFileSync("/dev/stdin", "utf8")
	.split(" ", 3)
	.map(Number.parseFloat)

console.log((distanceBetweenPalantirs / (diameterA + diameterB)).toFixed(2))

Copy The Code & Try With Live Editor

Input

x
+
cmd
100 2 2

Output

x
+
cmd
25.00

#3 Code Example with Python Programming

Code - Python Programming


n, x, y = [int(x) for x in input().split()]
print('{:.2f}'.format(n/(x+y)))
Copy The Code & Try With Live Editor

Input

x
+
cmd
100 2 2

Output

x
+
cmd
25.00
Advertisements

Demonstration


Previous
#2949 Beecrowd Online Judge Solution 2949 The Fellowship of the Ring Solution in C, C++, Java, Js and Python
Next
#2951 Beecrowd Online Judge Solution 2951 The Return of The King Solution in C, C++, Java, Js and Python