CodeForces765C
C. Table Tennis Game 2
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.
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的更多相关文章
随机推荐
- list页面-按照choice筛选丶传condition过滤筛选项丶筛选与显示同步
1.list页面:筛选功能优化,显示choices,传condition过滤筛选项 list_filter = [ # sites.FilterOption("name", ...
- 一,memcached的基本概念
1,memcached的基本概念 memcached是一个高效的分布式内存对象缓存系统,它可以支持把各种php的数据(array,对象,基本数据类型)放入到它管理的内存中.简单的说,memcached ...
- (4)Oracle基础--操作表中数据
· 添加数据 <1> INSERT 语句 ① 向表中所有字段添加值 语法: INSERT INTO table_name (column1,column2...) VALUES(val ...
- 转载-浅谈Ddos攻击攻击与防御
EMail: jianxin#80sec.comSite: http://www.80sec.comDate: 2011-2-10From: http://www.80sec.com/ [ 目录 ]一 ...
- hexo安装总结
博客原文地址:Claiyre的个人博客 如需转载,请在文章开头注明原文地址 hexo真心是一个不错的东西呢,安装简单(然而对博主来说并不是这样,伤心脸),主题样式简洁优雅,还有多种选择. 流程如下 安 ...
- 删除 Win10 更新后的 Z 盘符(已验证)
如果你有一些不希望被访客看见的文件.照片或者视频,希望将它隐藏在一个只有自己知道的地方,那么今天的这篇教程非常适合你.我们要实现的最终效果是这样的:在Win10的"此电脑"中,有这 ...
- iOS-Button图片和文字垂直居中【按钮图片和文字同时居中】
以前不怎么有这样的需求,最近开发经常用到,所以就干脆封装一个这样的 Button 让图片和字体都垂直居中,重写layoutSubviews方法,来实现就可以,至于 layoutSubviews 方法什 ...
- 【xsy1147】 异或(xor) 可持久化trie
我的脑回路可能比较奇怪. 我们对这些询问离线,将所得序列${a}$的后缀和建$n$棵可持久化$trie$. 对于一组询问$(l,r,x)$,我们在主席树上询问第$l$棵树$-$第r$+1$棵树中与$s ...
- Linux终端复用工具 tmux
简介 Terminal Multiplexer (From WIKIPEDIA) - A terminal multiplexer is a software application that can ...
- 漫谈NIO(1)之计算机IO实现
1.前言 此系列将尽可能详细介绍断更博客半年以来个人的一个成长,主要是对Netty的源码的一个解读记录,将从整个计算机宏观IO体系上,到Java的原生NIO例子最后到Netty的源码解读.不求完全掌握 ...