Chef and Remissness Codechef Solution

Hello Programmers In this post, you will know how to solve the Chef and Remissness Codechef Solution.

Chef and Remissness Codechef Solution
Chef and Remissness Codechef Solution

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Problem

Chef is now a corporate person. He has to attend office regularly. But chef does not want to go to office, rather he wants to stay home and discover different recipes and cook them.

In the office where chef works, has two guards who count how many times a person enters into the office building. Though the duty of a guard is 24 hour in a day, but sometimes they fall asleep during their duty and could not track the entry of a person in the office building. But one better thing is that they never fall asleep at the same time. At least one of them remains awake and counts who enters into the office.

Now boss of Chef wants to calculate how many times Chef has entered into the building. He asked to the guard and they give him two integers A and B, count of first guard and second guard respectively.

Help the boss to count the minimum and maximum number of times Chef could have entered into the office building.

Input

The first line of the input contains an integer T denoting the number of test cases. The description of the T test cases follows.

Each test case consists of a line containing two space separated integers A and B.

Output 

For each test case, output a single line containing two space separated integers, the minimum and maximum number of times Chef could have entered into the office building.

Constraints

  • 1 <= T <= 100
  • 0 <= A, B <= 1000000

Example

Input:

1
19 17

Output:

19 36

Chef and Remissness CodeChef Solutions in Python

T = int(input())
while T > 0:
    m, n = map(int, input().split())
    total = m + n
    print(max(m, n), total)
    T = T - 1

Chef and Remissness CodeChef Solutions in CPP

#include<stdio.h>
int main(){
    int p,a,b;
    scanf("%d",&p);
	  while(p--){
        scanf("%d %d",&a,&b);
        if(a > b){
            printf("%d %d\n",a,a+b);
        }
        else{
            printf("%d %d\n",b,a+b);
        }
	  }
	return 0;
}

Chef and Remissness CodeChef Solutions in JAVA

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for (int tc = 0; tc < T; tc++) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.printf("%d %d\n", Math.max(A, B), A + B);
		}
		sc.close();
	}
}
Ezoicreport this ad

Disclaimer: The above Problem (Chef and Remissness) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.

Next: Ciel and Receipt Codechef Solution

Sharing Is Caring

Leave a Comment

Ezoicreport this ad