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的更多相关文章
随机推荐
- MySQL(慢日志记录)
day63 参考:https://www.cnblogs.com/wupeiqi/articles/5716963.html
- (1)Oracle基础--用户与登录
一.用户 · 系统用户 <1> sys,system sys和system是权限比较高的用户,且sys比system权限高.使用sys登录必须使用sysdba或者sysoper的权限,而 ...
- nginx-限制后端服务器连接数
http加 limit_conn_zone $binary_remote_addr zone=perip:10m;limit_conn_zone $server_name zone=perserver ...
- 关于防止表单form重复提交的方式
表单重复提交: 1.第一种:添加以后刷新页面(刷新的是Servlet) 2.第二种:重复点击提交按钮. * 使用令牌机制:(防止表单重复提交) * 在表单页面中 生成一个令牌 * 将这个令牌保存在se ...
- (转)Oracle 12c Windows安装、介绍及简单使用(图文)
版权声明:http://blog.csdn.net/anxpp https://blog.csdn.net/anxpp/article/details/51345074 转载请注明出处:http:// ...
- (转)pt-online-schema-change在线修改表结构
原文:http://www.ywnds.com/?p=4442 一.背景 MySQL大字段的DDL操作:加减字段.索引.修改字段属性等,在5.1之前都是非常耗时耗力的,特别是会对MySQL服务产生影响 ...
- Delphi基础语法
1.LowerCase(const s:string):string.UpperCase(const s:string):string 2.CompareStr(const s1,s2:string) ...
- centos下kubernetes+flannel部署(旧)
更合理的部署方式参见<Centos下Kubernetes+Flannel部署(新)> 一.准备工作 1. 三台centos主机 k8s(即kubernetes,下同)master: 10. ...
- 恶性bug解决,Encoding 1252 data could not be found. Make sure you have correct international codeset assembly installed and enabled
百度是没有的,google了下 这句话的意思是编码1252没找到,确保程序及是国际化格式 发生在我使用unity读取xlsx文件,在编辑器运行正常,但是发布出来不正常,报错 解决方案: 链接:http ...
- Redis笔记(二):Redis数据类型
Redis 数据类型 Redis支持五种数据类型:string(字符串),hash(哈希),list(列表),set(集合)及zset(sorted set:有序集合). String(字符串) st ...