Given three integers, A, B and C. You have to find the number of days it will take to reach zero cases of Corona in a city.A - Average cases recovered in a day of the corona.B - Number of new cases of corona daily.C - Current active cases of the corona.Return the minimum number of days it will take to reach 0 active cases of Covid.Problem Constraints1 <= B < A <= 50001 <= C <= 1000Input FormatThe first argument will be integer A, which denotes the recovered cases in a day.The second argument will be integer B, which denotes the new cases in a day.The third argument will be integer C, which denotes the currently active cases.Output FormatReturn an integer which denotes the minimum days to reach 0 cases.Example InputInput 1:A = 5B = 3C = 1Input 2:A = 4B = 3C = 2
Question
Given three integers, A, B and C. You have to find the number of days it will take to reach zero cases of Corona in a city.A - Average cases recovered in a day of the corona.B - Number of new cases of corona daily.C - Current active cases of the corona.Return the minimum number of days it will take to reach 0 active cases of Covid.Problem Constraints1 <= B < A <= 50001 <= C <= 1000Input FormatThe first argument will be integer A, which denotes the recovered cases in a day.The second argument will be integer B, which denotes the new cases in a day.The third argument will be integer C, which denotes the currently active cases.Output FormatReturn an integer which denotes the minimum days to reach 0 cases.Example InputInput 1:A = 5B = 3C = 1Input 2:A = 4B = 3C = 2
Solution
To solve this problem, we need to calculate the number of days it will take for the number of recovered cases to exceed the number of new cases and the current active cases.
Here are the steps to solve this problem:
-
First, calculate the difference between the number of recovered cases and new cases per day. This will give us the net decrease in active cases per day. Let's call this value 'D'. So, D = A - B.
-
Next, divide the current active cases by 'D'. This will give us the number of days it will take for the active cases to reach zero if there were no new cases. However, since there are new cases every day, we need to add the number of days it takes for the new cases to be less than the recovered cases.
-
To find this, we divide the number of new cases by 'D'. This will give us the number of days it will take for the new cases to be less than the recovered cases.
-
Finally, we add the two values we calculated in steps 2 and 3. This will give us the minimum number of days it will take to reach zero active cases.
Here is the Python code for the above steps:
def min_days(A, B, C):
D = A - B
days_for_active_cases = C // D
days_for_new_cases = B // D
return days_for_active_cases + days_for_new_cases
You can call this function with the given inputs to get the minimum number of days. For example, min_days(5, 3, 1) will return 1 and min_days(4, 3, 2) will return 2.
Similar Questions
Help the doctorSabarish, A doctor forms a grid where each cell represents the condition of a patient. The cell can take any of the three values as follows: 1-The person is virus free 2-The person is infected with the virus 3-Empty cellIt takes one day for the virus to spread from one person to another. Every day any virus free person who is adjacent (4-directionally) to the infected person catches the disease.Given the initial grid help the doctor to find the minimum number of days that must elapse until everyone has been infected. If this impossible return -1.Example:-Suppose the input grid is 2 1 1 1 1 3 3 1 1After day 1 the grid will be 2 2 1 2 1 3 3 1 1After day 2 the grid will be 2 2 2 2 2 3 3 1 1 After day 3 the grid will be 2 2 2 2 2 3 3 2 1After day 4 the grid will be 2 2 2 2 2 3 3 2 2So, the minimum number of days is 4Input format:-Numbers of row in the gridNumbers of column in the gridContents of the grid(next row*column lines)Output format:-Minimum number of days required
Help the doctorSabarish, A doctor forms a grid where each cell represents the condition of a patient. The cell can take any of the three values as follows: 1-The person is virus free 2-The person is infected with the virus 3-Empty cellIt takes one day for the virus to spread from one person to another. Every day any virus free person who is adjacent (4-directionally) to the infected person catches the disease.Given the initial grid help the doctor to find the minimum number of days that must elapse until everyone has been infected. If this impossible return -1.Example:-Suppose the input grid is 2 1 1 1 1 3 3 1 1After day 1 the grid will be 2 2 1 2 1 3 3 1 1After day 2 the grid will be 2 2 2 2 2 3 3 1 1 After day 3 the grid will be 2 2 2 2 2 3 3 2 1After day 4 the grid will be 2 2 2 2 2 3 3 2 2So, the minimum number of days is 4Input format:-Numbers of row in the grid
A farmer has 14 employees who work all year round, and he hires some temporary employees at harvest time.Let b represent the number of temporary employees and c represent the total number of employees.Use the equation c=b+14 to find the value of c when b=10.c=
A new automobile company will manufacture 11 cars every month. It will first fill an overseas order for 8 cars and will send the rest to showrooms in New York.Let m represent the number of months and c represent the total number of cars sent to New York.Use the equation c=11m–8 to find the value of c when m=2.c=Submit
Given 3 integers A, B, and C such that A < B < CFind the value of max(A, B, C) - min(A, B, C)Here max(A, B, C) denotes the maximum value among A, B, C while min(A, B, C) denotes the minimum value among A, B, C.Input FormatThe first line of input will contain a single integer T, denoting the number of test cases.Each test case consists of 3 integers A, B, C.41 3 105 6 73 8 92 5 6Constraints1 <= T <= 101 <= A, B, C <= 10Output Format9264Sample Input 041 3 105 6 73 8 92 5 6Sample Output 09264Explanation 0Test case 1: Here, max(1,3,10)=10 and min(1, 3, 10) = 1. Thus, the difference is 9Sample Input 132 5 102 6 93 4 9Sample Output 1876
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.