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 ;
}

Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C的更多相关文章

  1. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) F. Souvenirs 线段树套set

    F. Souvenirs 题目连接: http://codeforces.com/contest/765/problem/F Description Artsem is on vacation and ...

  2. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding 拓扑排序

    E. Tree Folding 题目连接: http://codeforces.com/contest/765/problem/E Description Vanya wants to minimiz ...

  3. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) D. Artsem and Saunders 数学 构造

    D. Artsem and Saunders 题目连接: http://codeforces.com/contest/765/problem/D Description Artsem has a fr ...

  4. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C. Table Tennis Game 2 水题

    C. Table Tennis Game 2 题目连接: http://codeforces.com/contest/765/problem/C Description Misha and Vanya ...

  5. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B. Code obfuscation 水题

    B. Code obfuscation 题目连接: http://codeforces.com/contest/765/problem/B Description Kostya likes Codef ...

  6. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A. Neverending competitions 水题

    A. Neverending competitions 题目连接: http://codeforces.com/contest/765/problem/A Description There are ...

  7. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A B C D 水 模拟 构造

    A. Neverending competitions time limit per test 2 seconds memory limit per test 512 megabytes input ...

  8. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding

    地址:http://codeforces.com/contest/765/problem/E 题目: E. Tree Folding time limit per test 2 seconds mem ...

  9. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) D. Artsem and Saunders

    地址:http://codeforces.com/contest/765/problem/D 题目: D. Artsem and Saunders time limit per test 2 seco ...

  10. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C - Table Tennis Game 2

    地址:http://codeforces.com/contest/765/problem/C 题目: C. Table Tennis Game 2 time limit per test 2 seco ...

随机推荐

  1. jzyz集训 0228

    早上考了一波. 出题人是wangyurzee王队长,题目亲民,数据很水(除了第二题).用来做比赛很不错.(尽管我只有第一题A了). 第一题大意是给你n个操作,每个操作是将你手上的数字区间集合与给出的区 ...

  2. linuxshell,闲散命令记录

    1. 移动光标到 0:0 位置 printf "\033[0;0H" 2. 清屏 printf "\033[2J" 3. awk接收 外部变量 awk -v v ...

  3. codeforces A. Punctuation 解题报告

    题目链接:http://codeforces.com/problemset/problem/147/A 题目意思:给定一篇文章,需要对这篇文章进行编辑,使得:(1)两个单词之间有一个空格分开  (2) ...

  4. html5--5-16 综合实例绘制饼图

    html5--5-16 综合实例绘制饼图 实例 <!doctype html> <html> <head> <meta charset="utf-8 ...

  5. codeforces 669B B. Little Artem and Grasshopper(水题)

    题目链接: B. Little Artem and Grasshopper time limit per test 2 seconds memory limit per test 256 megaby ...

  6. springMVC之HttpServletRequest的getParameterMap()

    request.getParameterMap()的返回类型是Map类型的对象,也就是符合key-value的对应关系,但这里要注意的是,value的类型是String[],而不是String. 得到 ...

  7. POJ2823(优先队列)

    Sliding Window Time Limit: 12000MS   Memory Limit: 65536K Total Submissions: 50738   Accepted: 14590 ...

  8. zabbix snmp、jmx配置使用

    SNMP: snmp是很古老的监控,我萌几乎可以在所有设备上看到它的身影 [root@linux-node1 ~]# yum install net-snmp net-snmp-libs net-sn ...

  9. 修改SQL Server 2005的默认端口

    修改SQL Server 2005的默认端口 1.打开SQL Server的配置管理程序 Microsoft SQL Server 2005->配置工具->SQL Server Confi ...

  10. A-Z,a-z,0-9的unicode编码表

    1.转自:https://blog.csdn.net/fedawn/article/details/7307993 A-Z 的 Unicode 字符编码表     十进制  十六进制 1.“A”的 U ...