Chef and Chefina Solution

Problem

Given the time control of a chess match as a + b, determine which format of chess out of the given 4 it belongs to.

1) Chef if a + b \lt 3

2) Cfenia if 3 \leq a + b \leq 10

3) Chefina if 11 \leq a + b \leq 60

4) Cf if 60 \lt a + b

Input Format

  • First line will contain T, number of testcases. Then the testcases follow.
  • Each testcase contains a single line of input, two integers a, b.

Output Format

For each testcase, output in a single line.

Constraints

  • 1 \leq T \leq 1100
  • 1 \leq a \leq 100
  • 0 \leq b \leq 10

Subtasks

Sample 1:

Input
Output
4
1 0
4 1
100 0
20 5
1
2
4
3

Explanation:

TestCase 1: Since a + b = 1 \lt 3.

TestCase 2: Since 3 \leq (a + b = 5) \leq 10.




 

Program :


import java.util.*;

import java.lang.*;

import java.io.*;


/* Name of the class has to be "Main" only if the class is public. */

class Codechef

{

public static void main (String[] args) throws java.lang.Exception

{

    Scanner sc= new Scanner(System.in);

    int n=sc.nextInt();

    while(n-->0){

        int a=sc.nextInt();

        int b=sc.nextInt();

        int c= a+b;

        

        if(c<3)

        {

            System.out.println("1");

        }

        else if(c>=3 && c<=10) 

        {

            System.out.println("2");

        }

        else if(c>=11 && c<=60)

        {

            System.out.println("3");

        }

        else 

        {

            System.out.println("4");

        }

    }

}

}

Post a Comment

0 Comments