# Find an integer | codechef solution

## Problem

Chef has two nephews who love integers $�$ and $�$. An integer $�$ is awesome if the following conditions hold:

• $1\le �\le 1{0}^{18}$
• $\left(�+�\right)$ is divisible by $�$.
• $\left(�+�\right)$ is divisible by $�$.

Find any awesome integer $�$. We can prove that under the given constraints, an answer always exists.

Note that you do not have to minimize the answer.

### Input Format

• The first line of input will contain a single integer $�$, denoting the number of test cases.
• Each test case consists of a single line of input.
• The first line of each test case contains two space-separated integers $�$ and $�$ — favourite numbers of Chef's nephews.

### Output Format

For each test case, output an awesome integer. If there are several answers, you may print any of them.

### Constraints

• $1\le �\le 1{0}^{5}$
• $1\le �,�\le 1{0}^{9}$

### Sample 1:

Input
Output
3
18 42
1 1
100 200

192
5
500

### Explanation:

Test Case 1: In this case, $�=192$ is an awesome integer because:

• $1\le 192\le 1{0}^{18}$
• $192+18=210$ is divisible by $42$
• $192+42=234$ is divisible by $18$

Test Case 2: We can output any positive integer $�$ such that $\left(1\le �\le 1{0}^{18}\right)$ because $�+1$ is divisible by $1$ for all such $�$.

Code(C++):-

#include <iostream>
#include <numeric>
using namespace std;

int main() {
long long int t,i,a,b,c,d;
cin>>t;
for(i=0;i<t;i++){
cin>>a>>b;
c=gcd(a,b);
if(c!=min(a,b)){
d=(a/c)-1;
cout<<b*d-a<<endl;
}
else if(a!=b){
cout<<(max(a,b))-(min(a,b))<<endl;
}
else cout<<a+b<<endl;
}
return 0;
}

### Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-
iMocha coding Questions:-
Tech Mahindra coding questions:-
Unthinkable Solutions coding questions:-