Последовательный запрос решает его на C++C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Последовательный запрос решает его на C++

Сообщение Anonymous »


Alice is analyzing a mathematical sequence where the first element of the sequence is 'A' and the difference between any two consecutive elements is 'D'. She is given an integer 'X'.
Return 1 if 'X' appears in the sequence; else, return 0.
Example :
Input: 'A’ = 2, ‘D’ = 3, 'X' = 8
Output: 1
The sequence here is 2, 5, 8, 11, .... As 8 is present in the sequence, the output is 1.
Detailed explanation ( Input/output format, Notes, Images )
Constraints:
-10^9 ≤ A, D, X ≤ 10^9
Time limit: 1 sec
Sample Input 1:
1 2 7
Sample Output 1 :
1
Explanation For Sample Input 1:
The sequence here is 1, 3, 5, 7, .... As 7 is present in the sequence, the output is 1.
Sample Input 2:
5 0 3
Sample Output 2 :
0
Explanation For Sample Input 2:
The sequence here is 5, 5, 5, .... As 3 is not present in the sequence, the output is 0.
if anyone solve it please share its solution with me, please
i try it but here time limit exceed aa raha hain


Источник: https://stackoverflow.com/questions/781 ... ve-it-in-c
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»