Problem Statement-
This problem is taken from codechef December long challenge.Let's read Problems statement.
Increasing COVID cases have created panic amongst the people of Chefland, so the government is starting to push for production of a vaccine. It has to report to the media about the exact date when vaccines will be available.
There are two companies which are producing vaccines for COVID. Company A starts producing vaccines on day and it can produce vaccines per day. Company B starts producing vaccines on day and it can produce vaccines per day. Currently, we are on day .
We need a total of vaccines. How many days are required to produce enough vaccines? Formally, find the smallest integer such that we have enough vaccines at the end of the day .
Input
- The first and only line of the input contains five space-separated integers , , , and .
Output
Print a single line containing one integer ― the smallest required number of days.
Constraints
Subtasks
Subtask #1 (30 points):
Subtask #2 (70 points): original constraints
Example Input 1
1 2 1 3 14
Example Output 1
3
Explanation
Since , we can produce vaccines per day. In days, we produce vaccines, which satisfies our requirement of vaccines.
Example Input 2
5 4 2 10 100
Example Output 2
9
Explanation
There are vaccines produced on the first day, vaccines produced on each of days , and , and vaccines produced on the fifth and each subsequent day. In days, it makes a total of vaccines.
Solution -
Hint- This Problem can be solved using brute force approach.
Comments
Post a Comment