Rcb_vs_csk [] (https://www.codechef.com/PATN2021/problems/CRICMTC1)

[Practice](rcb_vs_csk [] (Contest Page | CodeChef))

Author: Aryan KD
Tester: Aryan KD
Editorialist: Aryan KD

DIFFICULTY:

CAKEWALK, SIMPLE, EASY.

PREREQUISITES:

Math .

PROBLEM:

Everyone knows INDIA is best in cricket. INDIA always finishesh every international match at top every year.

INDIA every year holds worlds biggest league match that is IPL ( cricket match league) . Like every year this year also IPL is going on . today’s match is between RCB vs CSK . this is going to be very interesting match .

RCB won the toss and decided to bat . now worlds most destructive duos on the crease , that is Abd and Virat . Today Abd is in different mood he is hitting all the ball outside the boundry , he is not giving strike to his partner Virat to play any ball .

How many maximum runs will Abd scores ? if he play all the ball . atleast 1 ball Abd will play .

RULE :

There is not any extra run that is No ball, freehit , wideball, overthrow , legby . They will run at most 3 run in 1 ball. One over consist of 6 balls , after every one over strike changes ( if Virat is on strike then next overs first ball Abd will play ) .

QUICK EXPLANATION:

you have given N number of ball played by abd and you have to just find out how many maximum run he will score .

EXPLANATION:

in given problm you have given N that is number of balls played by Abd you have just find out the how many max run he will score ? if he will play 6 ball then he will hit 6 sixes on six ball that is 36 run in similar way if he will play a 7 ball then he will hit 6 sixes on 6 balls and 3 run in remaining 1 ball thatis total 39 run .

SOLUTIONS:

Setter's Solution
  1. //rcb vs csk

  2. #include<bits/stdc++.h>

  3. using namespace std;

  4. void testcase()

  5. {

  6. int n;

  7. cin>>n;

  8. if(n%6==0){

  9. cout<<((((n/6)-1)*3)+((n-((n/6)-1))*6));

  10. }

  11. else {

  12. cout<<(((n/6)*3)+((n-(n/6))*6));

  13. }

  • }
  1. int main()

  2. {

  3. int t;

  4. cin>>t;

  5. while(t–)

  6. {

  7. testcase();

  8. cout<<endl;

  9. }

  10. return 0;

Tester's Solution
  1. //rcb vs csk

  2. #include<bits/stdc++.h>

  3. using namespace std;

  4. void testcase()

  5. {

  6. int n;

  7. cin>>n;

  8. if(n%6==0){

  9. cout<<((((n/6)-1)*3)+((n-((n/6)-1))*6));

  10. }

  11. else {

  12. cout<<(((n/6)*3)+((n-(n/6))*6));

  13. }

  • }
  1. int main()

  2. {

  3. int t;

  4. cin>>t;

  5. while(t–)

  6. {

  7. testcase();

  8. cout<<endl;

  9. }

  10. return 0;

Editorialist's Solution
  1. //rcb vs csk

  2. #include<bits/stdc++.h>

  3. using namespace std;

  4. void testcase()

  5. {

  6. int n;

  7. cin>>n;

  8. if(n%6==0){

  9. cout<<((((n/6)-1)*3)+((n-((n/6)-1))*6));

  10. }

  11. else {

  12. cout<<(((n/6)*3)+((n-(n/6))*6));

  13. }

  • }
  1. int main()

  2. {

  3. int t;

  4. cin>>t;

  5. while(t–)

  6. {

  7. testcase();

  8. cout<<endl;

  9. }

  10. return 0;