Skip to main content
Back to problems
Codeforces
Easy
Math
Simulation
Bear and Big Brother

Given two bears with different weights, determine how many years it takes for the first bear to become strictly heavier than the second if both grow at fixed annual rates.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Problem

Limak and Bob are bears with initial weights aa and bb kilograms, respectively, where a<ba < b.

Every year:

  • Limak's weight is multiplied by $3$.
  • Bob's weight is multiplied by $2$.

Your task is to determine the smallest number of years after which Limak's weight becomes strictly greater than Bob's weight.

Goal

Return that minimum number of years.

Notes

  • The weights grow exponentially by fixed factors.
  • You may simulate year by year until Limak overtakes Bob.

Input Format

  • A single line contains two integers aa and bb.
  • It is guaranteed that a<ba < b.

Output Format

  • Output one integer: the minimum number of years needed for Limak's weight to become strictly greater than Bob's weight.

Constraints

  • 1≤a<b≤1091 \le a < b \le 10^9
  • The answer fits in a 32-bit signed integer.
  • A simple simulation is sufficient.
Examples
Sample cases returned by the problem API.

Example 1

Input

4 7

Output

2

Explanation

After 1 year: Limak = 12, Bob = 14. After 2 years: Limak = 36, Bob = 28. Limak becomes strictly heavier in 2 years.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.