Time limit per test
1 second
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
Valera had two bags of potatoes, the first of these bags containsX(XLatency ≥ cost 1) potatoes,
And the second-Y(YLatency ≥ cost 1) potatoes.
Valera-very scattered boy, so the first bag of potatoes (it containsXPotatoes) Valera lost. Valera remembers that the total amount
Potatoes (XRegion + RegionY) In the two bags, firstly, was not geraterN,
And, secondly, was divisibleK.
Help Valera to determine how should potatoes cocould be In the first bag. Print all such possible numbers in ascending order.
Input
The first line of input contains three IntegersY,K,N(1 digit ≤ DigitY, Bytes,K, Bytes,NLimit ≤ limit 109; Limit ≤ limit 105 ).
Output
Print the list of whitespace-separated integers-all possible valuesXIn ascending order. You shoshould print each possible valueXExactly
Once.
If there are no such valuesXPrint a single integer-1.
Sample test (s) Input
10 1 10
Output
-1
Input
10 6 40
Output
2 8 14 20 26
Explanation: the idea of this question is very simple. Find a number that satisfies the following two formulas.
X + Y <= N
(X + y) % K = 0
Here we can take X + Y as a whole. Find the x + y that meets the requirements to find the corresponding X. Here we record x + y as M, in simple terms, the value range of m should be y to N, but note that X is definitely not 0, and Y is not necessarily divisible by K, so the minimum value of M is (y/k + 1) * k [here is not the same as Y + k value]. Then, increase the step size k until n.
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>using namespace std;int main() {int y,n,k,i;scanf("%d %d %d",&y,&k,&n);for(i=(y/k+1)*k;i<=n;i+=k){printf("%d ",i-y);}if((y/k+1)*k>n){printf("-1");}return 0;}