CF1181A.Chunga-Changa
入门
通过率:0%
时间限制:1.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Soon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called "chizhik". One has to pay in chizhiks to buy a coconut now.
Sasha and Masha are about to buy some coconuts which are sold at price z chizhiks per coconut. Sasha has x chizhiks, Masha has y chizhiks. Each girl will buy as many coconuts as she can using only her money. This way each girl will buy an integer non-negative number of coconuts.
The girls discussed their plans and found that the total number of coconuts they buy can increase (or decrease) if one of them gives several chizhiks to the other girl. The chizhiks can't be split in parts, so the girls can only exchange with integer number of chizhiks.
Consider the following example. Suppose Sasha has 5 chizhiks, Masha has 4 chizhiks, and the price for one coconut be 3 chizhiks. If the girls don't exchange with chizhiks, they will buy 1+1=2 coconuts. However, if, for example, Masha gives Sasha one chizhik, then Sasha will have 6 chizhiks, Masha will have 3 chizhiks, and the girls will buy 2+1=3 coconuts.
It is not that easy to live on the island now, so Sasha and Mash want to exchange with chizhiks in such a way that they will buy the maximum possible number of coconuts. Nobody wants to have a debt, so among all possible ways to buy the maximum possible number of coconuts find such a way that minimizes the number of chizhiks one girl gives to the other (it is not important who will be the person giving the chizhiks).
楚加-昌加岛被发现后不久,便开始逐渐形成某种文明,甚至出现了市场经济。一种新货币应运而生,俗称“奇日克”(chizhik)。如今购买一个椰子需支付 z 个奇日克。
萨沙有 x 个奇日克,玛莎有 y 个奇日克,她们计划一起购买若干椰子,每个椰子售价为 z 个奇日克。每位女孩仅使用自己的钱尽可能多地购买椰子,因此每人购买的椰子数量均为一个非负整数。
两位女孩讨论了各自的计划,发现:若其中一人将若干奇日克转给另一人,她们总共能购买的椰子总数可能增加(或减少)。由于奇日克不可分割,她们之间只能以整数个奇日克为单位进行交换。
考虑如下示例:假设萨沙有 5 个奇日克,玛莎有 4 个奇日克,每个椰子售价为 3 个奇日克。若她们不进行奇日克交换,则萨沙可买 1 个、玛莎可买 1 个,共买 1+1=2 个椰子。然而,若玛莎给萨沙 1 个奇日克,则萨沙有 6 个奇日克、玛莎有 3 个奇日克,此时她们可分别购买 2 个和 1 个椰子,共买 2+1=3 个椰子。
如今岛上生活并不轻松,因此萨沙和玛莎希望以某种方式交换奇日克,使得她们能购买的椰子总数达到最大值。此外,无人愿意欠债,因此在所有能使椰子总数达到最大值的交换方案中,需找出使一方给另一方的奇日克数量最小化的方案(具体由谁给出奇日克并不重要)。
输入格式
The first line contains three integers x, y and z (0≤x,y≤1018, 1≤z≤1018) — the number of chizhics Sasha has, the number of chizhics Masha has and the price of a coconut.
第一行包含三个整数 x、y 和 z(0≤x,y≤1018,1≤z≤1018)—— 分别表示萨沙拥有的奇日克数量、玛莎拥有的奇日克数量以及一个椰子的价格。
输出格式
Print two integers: the maximum possible number of coconuts the girls can buy and the minimum number of chizhiks one girl has to give to the other.
输出两个整数:女孩们最多能购买的椰子数量,以及一个女孩必须给另一个女孩的最小奇志克(chizhik)数量。
输入输出样例
输入#1
5 4 3
输出#1
3 1
输入#2
6 8 2
输出#2
7 0
说明/提示
The first example is described in the statement. In the second example the optimal solution is to dot exchange any chizhiks. The girls will buy 3+4=7 coconuts.
第一个示例在题目描述中已给出。在第二个示例中,最优策略是让任意两只“小刺猬”(chizhiks)进行交换。女孩们将购买 3+4=7 个椰子。
输入解题思路,AI测评打分。不知道怎么写?