Algorithm


Problem Name: 2 AD-HOC - beecrowd | 1708

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1708

Lap

 

By Vinícius "Cabessa" Fernandes dos Santos BR Brazil

Timelimit: 1

In motorsports it is very common that the leader pilot in a race, at a certain moment, overtakes the last pilot. The leader, at this moment, is one lap ahead of the last pilot, who then becomes a straggler. In this task, given the time it takes for the fastest pilot, and for the slowest pilot, to complete one lap, you have to determine in which lap the slowest pilot will become a straggler. You should consider that, at the beginning, they are side by side at the start line of the circuit, both at the start of lap number 1 (the first lap of the race); and that a new lap always begins right after the leader crosses the start line.

 

Input

 

The input contains several test cases. Each test case consists of one line with two integers X and Y (1X < Y ≤ 10000), the times, in seconds, that it takes for the fastest and the slowest pilot, respectively, to complete one lap.

 

Output

 

For each test case in the input program should output line, containing one integer: the lap in which the slowest pilot will become a straggler.

 

 

 

Sample Input Sample Output

5 7

4

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>
#include <math.h>

int main(void) {
   double a, b;

   scanf("%lf %lf", &a, &b);

   printf("%d\n", (int)ceil(b / (b - a)));

   return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 7

Output

x
+
cmd
4

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
   double a, b;

   cin >> a >> b;

   cout << ceil(b / (b - a)) << endl;

   return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 7

Output

x
+
cmd
4

#3 Code Example with Python Programming

Code - Python Programming


from math import ceil
e = str(input()).split()
a = int(e[0])
b = int(e[1])
print(ceil(b / (b - a)))

Copy The Code & Try With Live Editor

Input

x
+
cmd
5 7

Output

x
+
cmd
4
Advertisements

Demonstration


Previous
#1680 Beecrowd Online Judge Solution 1680 Edge Solution in C, C++, Java, Js and Python
Next
#1716 Beecrowd Online Judge Solution 1716 RSA Solution in C, C++, Java, Js and Python