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. React + webpack 环境配置

    安装配置Babel babel-preset-es2015 ES6语法包,使代码可以随意地使用ES6的新特性. babel-preset-react React语法包,专门用于React的优化,在代码 ...

  2. codeforces776D

    传送门 这题的意思就是原本有一个长度为n的01串,再给出m的长度为n的01串,要求你判定是否可以通过原串与m个串中的某些串xor使得原串到达一个状态.n,m小于1e5. 这题最初我发现不可做,因为这貌 ...

  3. hihocoder #1103 : Colorful Lecture Note微软苏州校招笔试 1月10日(字符串处理+栈)

    #1103 : Colorful Lecture Note 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi is writing an algorit ...

  4. 盈创动力之 JS校验方法

    var IS_NULL = 128; // 10000000var IS_FULL = 64; // 01000000var IS_HALF = 32; // 00100000var IS_ASCII ...

  5. 腾讯Hermes设计概要——数据分析用的是列存储,词典文件前缀压缩,倒排文件递增id、变长压缩、依然是跳表-本质是lucene啊

    转自:http://data.qq.com/article?id=817 三.Hermes设计概要 架构描述 系统核心进程均采用分散化设计,根据业务发展需求,可随意扩缩容机器; 周期性数据直接通过td ...

  6. Numpy中的flatten是按照什么方式进行工作。

    a = [[[1,2],[3,4]],[[5,6],[7,8]]] a = np.ndarray(a) array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) type ...

  7. 【CQ18高一暑假前挑战赛2】标程

    [昨晚打校赛,5个小时打完很累了,所以搞忘出题了...对不起学弟们,不过出的题都亲自写过一遍,可以保证题目和代码长度都不长,题目难度不大] [A:bush博弈] #include<bits/st ...

  8. [USACO 2008 MAR] 土地购买

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1597 [算法] 首先将所有土地按长为第一关键字 , 宽为第二关键字排序 显然 , 当 ...

  9. 纯css 图片自适应居中

    html 结构 <div class="container"> <div class="content"></div> &l ...

  10. 【224】◀▶ IDL NetCDF 文件操作说明

    参考:I/O - NetCDF Routines —— NetCDF 操作函数 01   NCDF_OPEN 打开一个 NetCDF 文件. 02   NCDF_CLOSE 关闭一个 NetCDF 文 ...