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 ≤ 109, 0 ≤ a, b ≤ 109, 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
Note

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.

题意:给出k,a,b,如果由一方先出现k点,则清零重新开始比赛,问根据a,b可以知道最多可以比几场

解法:首先可以猜出,a,b都小于k不符合要求,以及比赛成绩一定是ans=a/k+b/k,但是如果出现k点就清零,所以没有大于k是比分出现,也就是说a或者b大于k,而另一个小于k也是不符合要求的

 #include<bits/stdc++.h>
using namespace std;
int main()
{
int k,a,b;
cin>>k>>a>>b;
if(a>b)
{
swap(a,b);
}
if(a<k&&b<k)
{
cout<<"-1";
return ;
}
else if(a/k==&&b%k)
{
cout<<"-1";
return ;
}
int ans=(a/k+b/k);
cout<<ans<<endl;
return ;
}

最新文章

  1. .NET Core RC2/RTM 明确了时间表
  2. 计算机程序的思维逻辑 (44) - 剖析TreeSet
  3. 敏捷开发与jira之流程
  4. win10 系统怎么获取最高管理员权限删除文件
  5. UVa 11998 Broken Keyboard (数组模拟链表问题)
  6. php上传文件大小限制修改
  7. [转]关闭ORACLE数据库
  8. 创建租房网House脚本
  9. shell安装MySQL二进制包
  10. hdu 2578 Dating with girls(1)
  11. error: ‘for’ loop initial declarations are only allowed in C99 mode
  12. Bootstrap 基础教程
  13. (简单) POJ 3414 Pots,BFS+记录路径。
  14. 201521123117 《Java程序设计》第10周学习总结
  15. python学习之路基础篇(第五篇)
  16. Docker最全教程——从理论到实战(六)
  17. Fiddler无法正常抓取谷歌等浏览器的请求_解决方案
  18. 学以致用三十-----pycharm创建django项目忘记添加app
  19. 洛谷 P3975 [TJOI2015]弦论 解题报告
  20. OSGi 系列(三)之 bundle 详解

热门文章

  1. 最全的Android源码目录结构详解【转】
  2. iOS-个人开发者账号转公司开发者账号(邓白氏码申请教程)
  3. Jmeter参数化_CSV Data Set Config
  4. 精选Java面试题
  5. JavaScript实现按键记录,并在关掉网页之前把记录的内容post出去
  6. [ZJU 2112] Dynamic Rankings
  7. 简单易用&quot;里程碑&quot;、&quot;时间轴&quot;&lt;iOS小组件&gt;
  8. sqlServer:convert()函数
  9. 查看Spring源码的方法
  10. JAVA通过信号量避免死锁