Log Cutting Minimum Moves Calculation

Ninja, the log cutter, has 'K' axes and an infinite amount of logs. Using a log cutting stand with a capacity 'N', he can attempt to cut at most 'N' logs at a time. All axes are identical and can cut up to a certain number of logs in one attempt without breaking. An attempt to cut more than its capacity will break the axe, rendering it unusable. The goal is to determine how many logs can be cut with one axe in a single attempt without breaking it, using the minimum number of moves and the available axes.

Your task is to calculate the minimum number of moves required to find out the limit of logs an axe can cut without breaking.

Example:

Input:
Number of axes (K) = 2 AND Capacity of the log cutting stand (N) = 6
Output:
3
Explanation:

With the given input, the maximum number of moves needed using 2 axes with a capacity of 6 logs is 3.

Input format:

The first line contains an integer ‘T’ indicating the number of queries or test cases. Each subsequent line contains two space-separated integers ‘K’ (number of axes) and ‘N’ (capacity of log cutting stand).

Output format:

The minimum number of moves required for each test case, printed in separate lines.

Constraints:

  • 1 ≤ T ≤ 10
  • 1 ≤ K ≤ 100
  • 1 ≤ N ≤ 10000

Note:

You do not need to print anything, the function implementation will handle output.

Follow-Up:

Can this be solved with a worst-case time complexity of N1/3?

Be the first one to answer
Add answer anonymously...
Noon Academy Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter