Algorithm
problem Link : https://www.codechef.com/problems/KNGTOR
Problem
King loves to go on tours with his friends.
King has cars that can seat people each and cars that can seat people each. Determine the maximum number of people that can travel together in these cars.
Input Format
- The first line of input contains a single integer , the number of test cases.
- The first and only line of each test case contains two space-separated integers and — the number of -seaters and -seaters, respectively.
Output Format
For each test case, output on a new line the maximum number of people that can travel together.
Constraints
Sample 1:
4 4 8 2 13 14 5 8 8
76 101 105 96
Explanation:
Test case : King has cars that seat each and cars that seat each. So, people can travel together.
Test case : King has cars that seat each and cars that seat each. So, people can travel together.
Test case : King has cars that seat each and cars that seat each. So, people can travel together.
Test case : King has cars that seat each and cars that seat each. So, people can travel together.
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h> int main() { int t,n,m; scanf("%d",&t); while(t--) { scanf("%d %d",&n,&m); printf("%d\n",n*5+m*7); } }Copy The Code & Try With Live Editor
Input
4 8
2 13
14 5
8 8
Output
101
105
96
Demonstration
CodeChef solution KNGTOUR - Tour of King Codechef solution in C,C++