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. sublime-text-how-to-jump-to-file-from-find-results-using-keyboard

    http://209.116.186.231/#newwindow=1&q=sublime+text+find+results+jump http://stackoverflow.com/qu ...

  2. JavaScript基础流程控制(3)

    day51 参考:https://www.cnblogs.com/liwenzhou/p/8004649.html for循环 while循环 三元运算 a>b条件成立,选a,不成立选b

  3. [JavaScript] 时间戳格式化为yyyy-MM-dd日期

    function formateDate(timestamp){ var date = new Date(timestamp); var y = 1900+date.getYear(); var m ...

  4. snmpv3-snmpd.conf解析

    1.先指定createUser语句,设置密码和传输密钥. createUser user1 createUser user2 MD5 user2password createUser user3 MD ...

  5. day 49 数据分析, 数据聚合 F 查询 Q 查询

    6.聚合查询和分组查询 1.聚合查询aggregate 我们先通过一个例子来感受一下吧. 1 2 3 # 计算所有图书的平均价格 books = models.Book.objects.aggrega ...

  6. JAVA线程本地变量ThreadLocal和私有变量的区别

    ThreadLocal并不是一个Thread,而是Thread的局部变量,也许把它命名为ThreadLocalVariable更容易让人理解一些. 所以,在Java中编写线程局部变量的代码相对来说要笨 ...

  7. Java之集合(二十)LinkedBlockingQueue

    转载请注明源出处:http://www.cnblogs.com/lighten/p/7503678.html 1.前言 本章介绍阻塞队列LinkedBlockingQueue,这是一个基于链表的可选长 ...

  8. Spring Boot的listener简单使用

    监听器(Listener)的注册方法和 Servlet 一样,有两种方式:代码注册或者注解注册 1.代码注册方式 通过代码方式注入过滤器 @Bean     public ServletListene ...

  9. php 页面 不显示任何错误提示

    error_reporting(0); ini_set('html_errors',false); ini_set('display_errors',false);

  10. sql 时期格式整理

    我们经常出于某种目的需要使用各种各样的日期格式,当然我们可以使用字符串操作来构造各种日期格式,但是有现成的函数为什么不用呢? SQL Server中文版的默认的日期字段datetime格式是yyyy- ...