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 5 people each and  cars that can seat 7 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 5-seaters and 7-seaters, respectively.

Output Format

For each test case, output on a new line the maximum number of people that can travel together.

Constraints

  • 1≤�≤100
  • 0≤�,�≤100

Sample 1:

Input
 
Output
 
4
4 8
2 13
14 5
8 8
76
101
105
96

Explanation:

Test case 1: King has 4 cars that seat 5 each and 8 cars that seat 7 each. So, 4×5+8×7=76 people can travel together.

Test case 2: King has 2 cars that seat 5 each and 13 cars that seat 7 each. So, 2×5+13×7=101 people can travel together.

Test case 3: King has 14 cars that seat 5 each and 5 cars that seat 7 each. So, 14×5+7×7=105 people can travel together.

Test case 4: King has 8 cars that seat 5 each and 8 cars that seat 7 each. So, 8×5+8×7=96 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

x
+
cmd
4
4 8
2 13
14 5
8 8

Output

x
+
cmd
76
101
105
96
Advertisements

Demonstration


CodeChef solution KNGTOUR  - Tour of King Codechef solution in C,C++ 

Previous
CodeChef solution REACHTARGET - Reach the Target Codechef solution in C,C++
Next
CodeChef solution MINHEIGHT - Roller Coaster Codechef solution in C,C++