P20849 [GeeksforGeeks] Number of days4543
普及-
题目描述

Find the number of days required to reach the top of the staircase of Q stairs if one moves R stairs upwards during daytime and S stairs downwards during night.

Example 1:
Input:
R = 5, S = 1, Q = 6
Output:
2
Explanation:
After end of whole first day he will
end up at Stair number 4. Then the next
day, he will reach the top by climbing 2
more stairs.
Example 2:
Input:
R = 2, S = 1, Q = 3
Output:
2
Explanation:
After end of whole first day he will
end up at Stair number 1. Then the next
day, he will reach the top by climbing 2
more stairs.

Your Task:
You don't need to read input or print anything. Your task is to complete the function noOfDays() which takes 3 Integers R,S and Q as input and returns the answer.

Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Constraints:
1 <= S < R <= Q <= 10^{9}

输入格式

见题面

输出格式

见题面

样例输入
R = 5, S = 1, Q = 6
样例输出
2