CF765C.Table Tennis Game 2

普及-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins.

Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible.

Note that the game consisted of several complete sets.

米沙和万尼亚进行了若干场乒乓球比赛。每场比赛由若干次发球组成,每次发球由其中一名选手赢得,获胜者得 1 分,失败者不得分。一旦某名选手恰好获得 kk 分,当前比分即被清零,并开始新的一场比赛。

在所有比赛中,米沙总共获得了 aa 分,万尼亚总共获得了 bb 分。已知这些信息,请判断他们最多可能进行了多少场比赛;或者判断该情况是否不可能发生。

注意:整个比赛由若干场完整的比赛组成。

输入格式

The first line contains three space-separated integers k, a and b (1 ≤ k ≤ 109, 0 ≤ a, b ≤ 109, a + b > 0).

第一行包含三个以空格分隔的整数 kk、aa 和 bb(1 ≤ k ≤ 1091 \leq k \leq 10^9,0 ≤ a, b ≤ 1090 \leq a, b \leq 10^9,a + b > 0a + b > 0)。

输出格式

If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets.

如果这种情况不可能发生,则输出单个数字 -1。否则,输出可能的最大集合数量。

输入输出样例

  • 输入#1

    11 11 5

    输出#1

    1
  • 输入#2

    11 2 3

    输出#2

    -1

说明/提示

Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.

请注意,本题中的比赛规则与真实的乒乓球比赛规则不同,例如,“平分”规则(获胜方需领先对手至少两分才能赢得一局)在本题中不适用。

输入解题思路,AI测评打分。不知道怎么写?

首页