Description

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 k, a 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.

Sample Input

 题解:每一轮系列赛若要完成胜出的一方需要达到k分。此题分为两种情况:(1)a<k&&b<k;(2)c=max(a,b),c%k!=0&&min(a,b)<k输出-1,其他情况输出a/k+b/k;

(Input
11 11 5
Output
1
 #include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
using namespace std;
int main()
{
int i,j,n,ans=,t,k,ans1=,m,b,a;
scanf("%d%d%d",&a,&b,&n);
m=n>b?n:b;
k=n>b?b:n;
ans=m/a;
ans1=k/a;
if((ans==&&ans1==))
printf("-1\n");
else
{ if(m%a!=&&k<a)
printf("-1\n");
else
printf("%d\n",ans+ans1);
}
return ;
}

最新文章

  1. 如何创建多个Memcached服务
  2. navicat从下载到使用
  3. sql 游标循环当中重新赋值
  4. 【原创】_INTSIZEOF 内存按照int对齐
  5. CSS2书写顺序
  6. iPhone手机的屏幕尺寸、分辨率及适配
  7. windows下安装phpcms html/ 文件夹不可写的一种错误以及解决方法
  8. 数据挖掘_wget整站下载
  9. 将百度坐标转换的javascript api官方示例改写成传统的回调函数形式
  10. java亦或(^)
  11. getNextElement( )函数——获取下一个特定的元素节点
  12. kafka consumer 0.8.2.1示例代码
  13. C#如何使用REST接口读写数据
  14. js 字符串跟数组的相互转化
  15. c#new和override
  16. Junit中AssertTrue的使用
  17. sencha touch NavigationView
  18. mysql datetime与timestamp精确到毫秒的问题
  19. MAX II Device Compatibility with 5.0-V CMOS Devices
  20. BIEE物理业务层编辑之后发布路径

热门文章

  1. 不安装APK直接启动应用
  2. 原创:Angular新手容易碰到的坑,随时更新,欢迎订阅
  3. 用js 创建  简单查找 删除 二叉树
  4. centOS 7 tomcat nginx 验证码乱码
  5. Yet another A + B
  6. 《Troubleshooting SQL Server》读书笔记-内存管理
  7. Maven build标签
  8. Des加解密(Java端和Js端配套)解析
  9. Python学习系列(二)(基础知识)
  10. tomcat启动报错:org.springframework.beans.factory.BeanCreationException