#K7046. Taco: Maximum Sequence Length
Taco: Maximum Sequence Length
Taco: Maximum Sequence Length
Given three integers \(A\), \(B\), and \(D\), determine the maximum possible length of an arithmetic sequence that satisfies the following conditions:
- The sequence consists of integers in the range \([A, B]\) (inclusive).
- For every consecutive pair of terms \(P_i\) and \(P_{i+1}\), the difference is exactly \(D\), i.e., \(P_{i+1} - P_i = D\).
- It is assumed that \(D > 0\).
In other words, if the sequence is \(P = [P_1, P_2, \ldots, P_k]\), then we must have \(P_1 \ge A\), \(P_k \le B\), and for all \(1 \le i < k\), \(P_{i+1} = P_i + D\). Your task is to compute the maximum possible value of \(k\) (the sequence length) under these constraints.
inputFormat
The input consists of a single line containing three space-separated integers: \(A\), \(B\), and \(D\).
outputFormat
Output a single integer representing the maximum length of the arithmetic sequence that can be formed within the range \([A, B]\) with common difference \(D\).
## sample5 20 3
6