Algorithm


Problem Name: beecrowd | 1589

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

Bob Conduit

 

By Bruno Adami, Universidade de São Paulo - São Carlos BR Brazil

Timelimit: 1

You have gotten two circular energy cables. The first one has radius R1 and the second R2. You need to buy a circular conduit (see the image below) that fits those two cables:

What is the smallest radius of a conduit you need to buy? In other words, given two circles, what is the smallest radius of a third circle that circumscribe the other two?

 

Input

 

In the first line there is an integer T (T ≤ 10000), indicating the number of test cases.

 

On the only line of each test case we will have the two integers R1 and R2 indicating the cables radius. The integers will be positive and all the math will fit in a regular integer of 32 bits.

 

 

Output

 

In each test case, output the answer in a single line.

 

 

 

Sample Input Sample Output

3

1 1

2 8

8 2

2

10

10

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

int main()
{
    int test_cases{};
    std::cin >> test_cases;

    for (int i = 0; i  <  test_cases; ++i)
    {
        int r1{};
        int r2{};
        std::cin >> r1 >> r2;

        std::cout << r1 + r2 << '\n';
    }
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 1 1 2 8 8 2

Output

x
+
cmd
2 10 10

#2 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

const arroz = lines.shift();
let feijao = 0;

while(feijao  <  arroz){
  let [a, b] = lines.shift().split(" ");
  console.log(parseInt(a) + parseInt(b));
  feijao++;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 1 1 2 8 8 2

Output

x
+
cmd
2 10 10
Advertisements

Demonstration


Previous
#1588 Beecrowd Online Judge Solution 1588 Help the Federation Solution in C, C++, Java, Js and Python
Next
#1591 Beecrowd Online Judge Solution 1591 Grandma's Day Solution in C, C++, Java, Js and Python