Write a program that reads two integers and , both strictly greater than , followed by a sequence of integers, and finds out whether the sequence contains a consecutive subsequence of length at least that forms an arithmetic progression with step .
A consecutive subsequence of integers forms an arithmetic progression with step if the difference between two consecutive numbers equals . For instance, is an arithmetic progression with , and is an arithmetic progression with .
If the input sequence contains such a progression, the program must print a line with the first elements in the progression. Otherwise, the program must indicate "No arithmetic progression found with step r and length at least n".
The input consists of two integers and , followed by a sequence of integers containing at least 2 elements.
If a progression subsequence with reason and length at least exists, the output are the first elements of the progression. Otherwise, the output is "No arithmetic progression found with step r and length at least n".
Author: ProAl
Generation: 2026-01-25T17:02:55.462Z
© Jutge.org, 2006–2026.
https://jutge.org