Many numbers

2.1

21 votes
Sorting, Integer, Modulus Arithmetic, Modules, C++, Number Theory, Mathematics
Problem

You are given two numbers N and M. Your task is to print an array A such that:

  • Ai  is in the range [L:R]
  • A is sorted in increasing order
  • N % Ai = N % M
  • Ai !=M

The array can be of a large size. Therefore, if the array size is strictly more than K, then you must skip the task and print 1.

Input format

  • First line: N and M
  • Second line: L and R
  • Third line: K

Output format

The format of the output is as follows:

  • First line: Print the length of the required array.
  • Second line: Print N integers that denote the required array or print 1 if the required array length is more than K.

Constraints

1N, M10121L, R1012, L<=R0K105

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

15%7=1

so let's check for the numbers in [L:R]

(15%1=0) , (15%2=1) ,(15%3=0),(15%4=3),(15%5=0),(15%6=3),(15%8=7),(15%9=6),(15%10=5)

so the only number that works is 2 

Editor Image

?