Chef and Chefina: CFCFNA

CU Submission link: Click here (need login by CU account)

Chef and Chefina Codechef Solution in C++, Java, Python

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

1)1) Chef if a+b<3a+b<3

2)2) Cfenia if 3≤a+b≤103≤a+b≤10

3)3) Chefina if 11≤a+b≤6011≤a+b≤60

4)4) Cf if 60<a+b60<a+b

Input Format

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

Output Format

For each testcase, output in a single line.

Constraints

  • 1≤T≤11001≤T≤1100
  • 1≤a≤1001≤a≤100
  • 0≤b≤100≤b≤10

Subtasks

Sample Input 1

4
1 0
4 1
100 0
20 5

Sample Output 1

1
2
4
3

Explanation

TestCase 11: Since a+b=1<3a+b=1<3.

TestCase 22: Since 3≤(a+b=5)≤103≤(a+b=5)≤10.


Chef and Chefina Codechef Solution in C

int main()
{

// your code goes here
    int t;
	scanf("%d",&t);
	while(t--)
	{

	int p,q,r;
	scanf("%d %d",&p,&q);
	r=p+q;
        if(r < 3) {
		printf("1\n");
	}
        else if (r>=3 && r <= 10) {
		printf("2\n");
	}
	    else if (r>=11 && r <= 60) {
		printf("3\n");
	}
	         else if (r>60) {
		printf("4\n");
	}
	}
	return 0;
}

Chef and Chefina Codechef Solution in C++ 14

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a,b,c;
        cin>>a>>b;
        c=a+b;
        if(c < 3) {
           cout << 1 << endl;
        }
        else if (c>=3 && c <= 10) {
            cout << 2 << endl;
        }

         else if (c>=11 && c <= 60) {
            cout << 3 << endl;
        }

         else if (c>60)
            cout << 4 << endl;

    }
    return 0;
}

Chef and Chefina Codechef Solution in Java

/* package codechef; // don't place package name! */

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
	{
		// your code goes here
		  Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->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 if (c>60)
System.out.println("4");
}
	}
}


Chef and Chefina Codechef Solution
The content uploaded on this website is for reference purposes only. Please do it yourself first.