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.
- Chef if a + b \lt 3a+b<3
- Cfenia if 3 \leq a + b \leq 103≤a+b≤10
- Chefina if 11 \leq a + b \leq 6011≤a+b≤60
- Cf if 60 \lt a + b60<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
Sample
Input
4
1 0
4 1
100 0
20 5
Output
1
2
4
3
Explanation
TestCase 1: Since a+b=1<3.
TestCase 2: Since 3≤(a+b=5)≤10.
Solution
#include <iostream>
using namespace std;
class Chess{
int a,b,c;
public:
void game();
};
void Chess::game(){
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
cout<<4<<endl;
}
int main() {
// your code goes here
int t;
cin>>t;
Chess c;
while(t--){
c.game();
}
return 0;
}
/* 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
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int a=sc.nextInt();
int b=sc.nextInt();
if(a+b<3)System.out.println("1");
else if (3<=a+b&&a+b<=10)System.out.println("2");
else if (11<=a+b&&a+b<=60)System.out.println("3");
else System.out.println("4");
}
}
}
# cook your dish here
for _ in range(int(input())):
a,b=map(int,input().split())
if (a+b)<3:
print("1")
elif (a+b)<=10 and (a+b)>=3:
print("2")
elif (a+b)<=60 and (a+b)>=11:
print("3")
else:
print("4")
Please First Try to Solve Problem by Yourself.