Given two integers A and B representing the time taken by two different Sand timers to get empty. The task is to find the count of flips of each timer till the instance at which both the Sand timers get empty at the same time.
Input: A = 30, B = 15
Output: 0 1
After 15 minutes: 15 0
Flip timer 2: 15 15
After another 15 minutes: 0 0
Input: A = 10, B = 8
Output: 3 4
Approach: Lowest Common Factor (LCM) of two number will determine the time at which both the Sand timers will get empty together.
LCM(A, B) = (A * B) / GCD(A, B)
Dividing the LCM by input will give the number of flips for each sand timer respectively.
- Horizontally Flip a Binary Matrix
- Minimum flip required to make Binary Matrix symmetric
- Secretary Problem (A Optimal Stopping Problem)
- Counting Sort
- Counting numbers of n digits that are monotone
- Rencontres Number (Counting partial derangements)
- Counting numbers whose difference from reverse is a product of k
- Transportation Problem | Set 7 ( Degeneracy in Transportation Problem )
- Fibonacci problem (Value of Fib(N)*Fib(N) - Fib(N-1) * Fib(N+1))
- 21 Matchsticks Problem
- Tiling Problem
- Transportation Problem | Set 5 ( Unbalanced )
- Transportation Problem | Set 1 (Introduction)
- Cake Distribution Problem
- The Lazy Caterer's Problem
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.