cf148div2

来源:互联网 发布:王者荣耀引流源码 编辑:程序博客网 时间:2024/06/06 02:36
A. Two Bags of Potatoes
timelimit per test
1 second
memorylimit per test
256 megabytes
input
standard input
output
standard output

Valera had two bags of potatoes, the first of these bagscontains x (x ≥ 1) potatoes,and the second — y (y ≥ 1) potatoes.Valera — very scattered boy, so the first bag of potatoes (itcontains x potatoes)Valera lost. Valera remembers that the total amount ofpotatoes(x + y) inthe two bags, firstly, was not geraterthan n,and, secondly, was divisible by k.

Help Valera to determine how many potatoes could be in the firstbag. Print all such possible numbers in ascending order.

Input

The first line of input contains threeintegers ykn (1 ≤ y, k, n ≤ 109; cf148div2  ≤ 105).

Output

Print the list of whitespace-separated integers — all possiblevalues of x inascending order. You should print each possible valueof xexactlyonce.

If there are no such values of x printa single integer -1.

Sample test(s)
input
10 1 10
output
-1
input
10 6 40
output
2 8 14 20 26 

题意:求(x+y)%k==0中x可能的取值。
#include
#include
#include
using namespace std; 
int main() 
{    int y,n,k;
    while(scanf("%d%d%d",&y,&k,&n)!=EOF) 
{        int flag=0; 
for(int i=k;i<=n;i+=k) 
{            if(i>y) 
{                printf("%d ",i-y);                flag=1;            }
        }        if(flag==0)        {            printf("-1");        }        printf("\n");    }    return 0;}