Codeforces Bear and Big Brother solution

Codeforces Problem 791/A. Bear and Big Brother solution with CPP 100% Accepted

Before seeking assistance, it is advisable to make an effort to solve the problem yourself. This can involve researching the problem online, reviewing relevant documentation, and attempting to apply your knowledge to find a solution. By trying to solve the problem first, you can gain a better understanding of the issue and also improve your problem-solving skills. It also demonstrates to others that you have made an effort to solve the problem before seeking help.

Codeforces Problem 791/A. Bear and Big Brother solution with CPP

Question link

Code explanation

The given program takes two integer inputs ‘a’ and ‘b’ from the user, then runs a loop that repeats until ‘a’ becomes greater than ‘b’. Inside the loop, the values of ‘a’ and ‘b’ are updated by multiplying ‘a’ by 3 and ‘b’ by 2 respectively. The loop also contains an if statement to check if ‘a’ is greater than ‘b’, if so, the loop terminates using the break statement. The loop counter ‘i’ keeps track of the number of iterations it takes for ‘a’ to become greater than ‘b’. Finally, the program outputs the value of ‘i’.

Bear and Big Brother

#include<iostream>

using namespace std;
int main()
{
int a,b,i;
cin>>a>>b;

for(i=1;;i++){
a=a*3; b=b*2;
if(a>b)

break;
}

cout<<i;

}

Codeforces 236A Boy or Girl Solution

1 thought on “Codeforces Bear and Big Brother solution”

  1. Pingback: Codeforces 546A. Soldier and Bananas solution in C++ - Free Code Center

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
NEW TOXIC ROCKET CYCLE DECK in Clash Royale 2023 Best Deck in Clash Royale Best Deck for Arena 8 in Clash Royale Best Hog deck for Pro players Best Clash Royale Deck