DICE-EDITORIAL

problem link:

https://www.codechef.com/CLAG2020/problems/DICE

Author:dhussa_09 | CodeChef User Profile for Tejas Dhussa | CodeChef

Tester:dhussa_09 | CodeChef User Profile for Tejas Dhussa | CodeChef

Translator:dhussa_09 | CodeChef User Profile for Tejas Dhussa | CodeChef

Editorialist:dhussa_09 | CodeChef User Profile for Tejas Dhussa | CodeChef

DIFFICULTY:
SIMPLE

** PREREQUISITES:**
LOGIC

PROBLEM:

Chef has total 2 dice with him.

one dice he gives to a robot.

another dice he gives you to play.

And starts the game……

1st dice will be thrown by a robot automatically. 2nd dice will be thrown by you if “necessary”.

your competitor chef will give you a challenge between the two cases.

case (N=1): Bring total sum of both dice below and equal to six.

case (N=2): Bring total sum of both dice above 6 and (below and equal to twelve).

so you accept his challenge.

If there is a chance that you can win then print WIN and also find the minimum number you should get on the second dice to win and print it on 2nd line. If there is no need of number on second dice print "0 "on next line followed by WIN as there is no need to throw the second dice in this case.

if it is not possible to win, print a single line LOOSE.

Note: The robot has a unique dice which can give any number between 1 to 12. dice you have got is standard dice on which any number between 1 to 6 can appear.

EXPLANATION:

Initially, there are 2 dice.

one dice will be thrown by robot always.

you are going to throw the dice after the chef gives the challenge.

chef challenge has 2 cases.
1]when he says n=1.
when n=1, there are 2 possibilities either you can win or loose

  • 1st possibility: winning-when number appeared on dice thrown by the robot is less than or equal to six. In this case, you print win and 0(as there no need to throw the second dice you
    have)

  • 2nd possibility: your lose-when number appeared on dice thrown by the robot is greater than six. In this case, you print LOOSE as you required number less than or equal to six according to chefs challenge(N=1).

2]when he says n=2.
when n=2, there is only one possibility you win.
but it has two cases.
let consider, number appeared on dice thrown by the bot is a.

  • 1st case: winning-when number appeared on dice thrown by the robot is anything between
    1 to 12 then you can win. if the number(a) appeared is less than or equal to six than you need
    the number(7-a) on the second dice and you will win.so, print WIN and number(7-a) you
    required on 2nd dice to win as (N=2).
  • 2nd case: when number appeared on dice thrown by a bot is greater than 6 than no need to throw the second dice. In this case, you print win and 0(as there no need to throw the second dice you have).

The solution in c++14 language:

#include
using namespace std;

int main() {
int T,A,B;cin>>T;
while(T–)
{
cin>>A>>B;
if(A==1)
{
if(B<=6)
{
cout<<“WIN”<<endl<<“0”<<endl;
}
else
{
cout<<“LOOSE”<<endl;
}

   }
   else if(A==2)
   {
       
        if(B>6 and B<=12)
        {
            cout<<"WIN"<<endl<<"0"<<endl;
        }
        else  if(B<=6)
        {
           cout<<"WIN"<<endl<<7-B<<endl;
        }
   }        
}
return 0;

}