C. Table Tennis Game 2

time limit per test:2 seconds
memory limit per test:512 megabytes
input:standard input
output:standard output

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.

 //2017-02-14
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int main()
{
long long k, a, b;
while(cin>>k>>a>>b)
{
long long ans = a/k+b/k;
if(ans == && a+b > )cout<<"-1"<<endl;
else if(a < k && b%k != )cout<<"-1"<<endl;
else if(b < k && a%k != )cout<<"-1"<<endl;
else cout<<ans<<endl;
} return ;
}

CodeForces765C的更多相关文章

随机推荐

  1. mysql 数据备份 crontab

    每天凌晨 2 点备份数据 crontab -e 0 2 * * * mysqldump ${mysqldir}/bin/mysqldump  -h$host -P$port -uadmin -p&qu ...

  2. zoj3497 Mistwald(矩阵快速幂)

    题意:给定一个有向图(最多25个节点,每个节点的出度最多为4),给定起点和终点,然后从起点开始走,走到终点就停止,否则一直往下走,问能不能P步到达终点.也就是说从起点出发,走一条长度为P的路径,路径中 ...

  3. Youke365_2_4 一处Sql注入漏洞以及一处任意文件删除

    本文作者:X_Al3r Prat 0 自白 每一天都是新的一天.没啥吐槽的,步入正题 /system/category.php 文件一处Sql注入## 80-87行代码         $root_i ...

  4. fluentd 推送 mariadb audit log

    说明: mariadb audit log是 mariadb 的审计日志 目的是把日志拆分成 tab 键分隔的字段 直接附上 fluentd 配置文件 <system> log_level ...

  5. 酷!美国国家安全局(NSA)开源了逆向工程工具 Ghidra

    简评:2019 RSA 大会期间,NSA 正式发布了这个工具.免费 + 开源,真的有吸引力,据说体验可以和 IDA 一较高下. Ghidra 是由美国国家安全局(NSA)研究理事会创建和维护的软件逆向 ...

  6. 【GDKOI2017】 两个胖子萌萌哒 小学奥数题

    题目大意:给你一个$n\times m$的网格,你要在这个网格上画三角形. 三角形的顶点只能在网格的整点上,且至少有一条边平行于$x$或$y$轴,且三角形面积为整数.问你能画多少个不同的三角形. 两个 ...

  7. 【NOIP2017】 宝藏 状压dp

    为啥我去年这么菜啊..... 我现在想了$20min$后打了$10min$就过了$qwq$. 我们用$f[i][j]$表示当前深度为$i$,访问了状态$j$中的所有点的最小代价. 显然$f[i][j] ...

  8. 剑指offer四十之数组中只出现一次的数字

    一.题目 一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序找出这两个只出现一次的数字. 二.思路 建一个hashMap,统计各数字出现的次数,然后遍历hashMap,输出出现一次的数字 ...

  9. IKAnalyzer 独立使用 配置扩展词典

    有三点要注意(要不然扩展词典始终不生效): 后缀名.dic的词典文件,必须如使用文档里所说的 无BOM的UTF-8编码保存的文件.如果不确定什么是  无BOM的UTF-8编码,最简单的方式就是 用No ...

  10. MapReduce求最大值最小值问题

    import java.io.File; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import ...