A. Two bags of potatoes

Source: Internet
Author: User
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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.