Please Fill out the Feedback Form for Code Radius

Chef and Chefina : CFCFNA | Codechef Solution

2 min read

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 3a+b<3
  2. Cfenia if 3 \leq a + b \leq 103≤a+b≤10
  3. Chefina if 11 \leq a + b \leq 6011≤a+b≤60
  4. Cf if 60 \lt a + b60<a+b.

Input Format

  1. First line will contain T, number of testcases. Then the testcases follow.
  2. 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

cpp
#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; }

Please First Try to Solve Problem by Yourself.

You may like these posts

  • Problem The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Ou…
  • Problem Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him…
  • Problem Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash …
  • Problem Write a program to obtain a number NN and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1. Please Share this article... …
  • Problem Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.Relational Operators are operators which check relati…
  • Problem In a Chess match "a + b", each player has a clock which shows a minutes at the start and whenever a player makes a move, b seconds are added to this player's clock. Ti…

Post a Comment