Many numbers
Practice
2.1 (21 votes)
Sorting
Integer
Modulus arithmetic
Modules
C++
Number theory
Mathematics
Problem
90% Success 5509 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code
You are given two numbers \(N\) and \(M\). Your task is to print an array \(A\) such that:
- \(A_{i}\) is in the range \([L : R]\)
- \(A\) is sorted in increasing order
- \(N \ \% \ A_{i}\) = \(N\ \%\ M\)
- \(A_{i}\) \(!= 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
\(1\le N,\ M\le 10^{12}\\ 1\le L,\ R\le 10^{12},\ L<=R\\ 0\le K\le 10^5\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
13 votes
Tags:
MathematicsModular arithmeticEasy-Medium
Points:30
5 votes
Tags:
Easy-Medium
Points:30
3 votes
Tags:
MathematicsModular arithmeticEasy-Medium
Editorial