码迷,mamicode.com
首页 > 其他好文 > 详细

CF765C Table Tennis Game 2

时间:2017-02-15 00:16:39      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:sts   rate   pac   span   imu   blog   ber   数学   core   

题意:

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.

Input

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

Output

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

Examples
input
11 11 5
output
1
input
11 2 3
output
-1

思路:

数学题。

实现:

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 
 5 int k, a, b;
 6 int main()
 7 {
 8     cin >> k >> a >> b;
 9     if (a < k && b % k || b < k && a % k)
10         puts("-1");
11     else
12         cout << a / k + b / k << endl;
13     return 0;
14 }

 

CF765C Table Tennis Game 2

标签:sts   rate   pac   span   imu   blog   ber   数学   core   

原文地址:http://www.cnblogs.com/wangyiming/p/6399358.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!