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}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def noOfDays(self, R, S, Q):

        # code here

Solutions:
import math

class Solution:

	def noOfDays(self, R, S, Q):
		return math.ceil((Q - S) / (R - S))


class Solution:

	def noOfDays(self, R, S, Q):
		return math.ceil(1.0 * (Q - S) / (R - S))


class Solution:

	def noOfDays(self, X, Y, Q):
		d = Q - X
		f = d // (X - Y)
		if d % (X - Y) != 0:
			f += 1
		return f + 1


class Solution:

	def noOfDays(self, R, S, Q):
		day = R - S
		count = 0
		if Q >= R:
			Q -= R
		if Q % day == 0:
			return Q // day + 1
		else:
			return Q // day + 2


class Solution:

	def noOfDays(self, R, S, Q):
		if S >= R:
			return -1
		sp = R - S
		Q -= R
		ans = Q / sp
		if int(ans) == ans:
			return int(ans) + 1
		return int(ans) + 2


class Solution:

	def noOfDays(self, R, S, Q):
		ans = (Q - S) // (R - S)
		if (Q - S) % (R - S):
			return ans + 1
		return ans
		return ans


class Solution:
	import math

	def noOfDays(self, R, S, Q):
		import math
		if R >= Q:
			return 1
		res = R - S
		ans = math.ceil((Q - R) / res)
		return ans + 1