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的更多相关文章
随机推荐
- Python拾遗
for...else...语句 用 break 关键字终止当前循环就不会执行当前的 else 语句,而使用 continue 关键字快速进入下一论循环,或者没有使用其他关键字,循环的正常结束后,就会触 ...
- hdoj1373 Channel Allocation(极大团)
题意是有若干个接收器,给出每个接收器的相邻接收器.相邻的接收器不能使用同一信号频道.问所需要的信号频道数. 求该无向图的极大团. #include<iostream> #include&l ...
- 约瑟夫(Josephus)问题~转
本文都是转的,一个是转博客,一个是转贴吧,前者详细,后者"强,无敌"! 博客转: 以前就知道约瑟夫问题是模拟,今天我才发现一些约瑟夫问题可以使用数学解法得出!真是强悍啊!约瑟夫问题 ...
- Ubuntu“无法打开锁文件(Could not get lock)”问题解决
用apt-get安装软件时提示: 无法获得锁 /var/lib/dpkg/lock - open(11:资源暂时不可用) 无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它? 其 ...
- iOS下载图片失败
一.具体问题 开发的过程中,发现某个界面部分图片的显示出现了问题只显示占位图片,取出图片的url在浏览器却是能打开的,各种尝试甚至找同行的朋友帮忙在他们项目里展示都会存在问题,最终发现通过第三方框架S ...
- HttpContext rewritePath后中文乱码
文章为转载 由于种种原因,最近将服务器上部署的网站修改4.0框架.但悲剧的问题出现了,发现搜索中文的时候关键词都成乱码了. 在网上查找相关资料得到几种相关解决方案如下: 服务器打补丁server200 ...
- 用AR.js实现webAR(新手入门)
开发需要准备的东西: ** 域名 命名 这里是测试
- BugFree3.0.4Linux环境安装指南
bugfree安装的前提是配置LAMP(apache+mysql+php),我安装的linux系统是centos6.0 一.安装Apache服务器 1.安装apache yum install htt ...
- [转] TCPIP 网络协议层对应的RFC文档
TCPIP网络协议层对应的RFC文档 RFC - Request For Comments 请求注解 TCP/IP层 网络协议 RFC文档 Physical Layer Data Link Layer ...
- Android输入控件EditText和软键盘监听
1. 跳转到新的页面自动软键盘显示情况: 在配置清单文件AndroidManifest.xml文件,对Activity的windowSoftInputMode属性进行设置. stateUnspecif ...