Problem E. Approve or Reject: 1000 Ms Linux
Problem E. Approve or Reject: 1000 Ms Linux
A manufacturing project has K tasks that need to be completed. The goal is to hire K teams, one
for each task, such that all teams start working together and the project is completed in X days.
Each team has at least one worker, and a team of A workers will complete their task in A days.
The teams work independently and submit their results for approval on the A-th day. If the
project is not completed on the X-th day, the teams whose results were rejected submit new
results on every A, 2A, 3A day, and so on.
Find the smallest number of workers needed to complete the project in X days.
Input
-The first line of the input contains a single integer T denoting the number of test cases. -The
following T lines contain two space-separated integers, K and X, representing the number of
tasks and the number of days the board wants the project to be completed in, respectively.
Output
For each test case, print a single line containing the smallest number of workers required to
complete the project in X days.
Constraints:
1 ≤ T ≤ 40
2 ≤ K, X ≤ 106
Sample 1
Input Output
2 4
2 3 5
2 6
Example case 1: We can hire 1 worker for task 2 and a team of 3 workers for task 1. The 1 man
team working on task 2 completes it and submits the result for approval on each day, but it is
rejected on the 1st and 2nd day. On the 3rd day, the team working on task 1 also completes their
task, so the project gets approved after exactly 3 days.
Example case 2: We can hire a team of a team of 2 workers for task 2 and 3 workers for task 1.