哈工大 sse C语言 困难

Q1892.(10分数, 语言: C)Two Bags of Potatoes
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Valera had two bags of potatoes, the first of these bags contains x (x≥1)
potatoes, and the second — y (y≥1) potatoes. Valera — very scattered
boy, so the first bag of potatoes (it contains x potatoes) Valera lost.
Valera remembers that the total amount of potatoes (x+y) in the two bags,
firstly, was not gerater than n, and, secondly, was divisible by k.
Help Valera to determine how many potatoes could be in the first bag.
Print all such possible numbers in ascending order.
Input
The first line of input contains three integers y, k, n (1≤y,k,n≤10^9;
n/k≤10^5).
Output
Print the list of whitespace-separated integers — all possible values
of x in ascending order. You should print each possible value of x exactly
once. If there are no such values of x print a single integer -1.

中文翻译:

题目描述

瓦莱拉有两个装满土豆的袋子。第一个袋子里有x(x≥1)个土豆,第二个袋子里有y(y≥1)个土豆。瓦莱拉是一个非常粗心大意的男孩,所以他丢失了第一个袋子(里面装有x个土豆)。

瓦莱拉记得,这两个袋子里的土豆总数(x+y)首先不会超过n,其次这个总数能被k整除。

请帮助瓦莱拉确定第一个袋子里可能有多少个土豆。按照升序打印出所有可能的数字。

输入

输入的第一行包含三个整数y, k, n(1≤y,k,n≤10^9;n/k≤10^5)。

输出

打印一个由空格分隔的整数列表——所有可能的x值,按照升序排列。每个可能的x值应该只打印一次。如果没有这样的x值,打印单个整数-1。

题目分析

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值