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的更多相关文章
随机推荐
- 七,apache配置域名
配置域名服务器流程: (1)在httpd.conf中启用虚拟主机,Include conf/extra/httpd-vhosts.conf前面的#去掉. (2)在httpd.conf中修改项目路径为自 ...
- Java并发工具类之CountDownLatch
CountDownLatch允许一个或则多个线程等待其他线程完成操作. 假如我们有这样的需求:我们需要解析一个excel文件中的多个sheet,我们可以考虑使用多线程,每一个线程解析excel中的一个 ...
- 使用Dockerfile定制镜像
Dockerfile是一个文本文件,其中包含额一条一条的指令,每一条指令构建一层,因此每一条指令的作用就是描述这一层应当如何的构建. 以构建nginx镜像为例,使用Dockerfile构建的步骤如下: ...
- ffmpeg + nginx 搭建流媒体
//安装nginx rtmp 流媒体服务 1.安装nginx+rtmp模块 brew install nginx-full --with-rtmp-module 2.修改配置文件 /usr/loca ...
- EF基础知识小记三(设计器=>数据库)
本文主要介绍通过EF的设计器来同步数据库和对应的实体类.并使用生成的实体上下文,来进行简单的增删查该操作 1.通过EF设计器创建一个简单模型 (1).右键目标项目添加新建项 (2).选择ADO.Net ...
- Android 开发工具类 26_getFile
从网络获取可执行文件 public void getFile() throws Exception{ // 首先得到请求的路径 String urlpath = "http://ftpcnc ...
- tomcat启动(二)org.apache.catalina.startup.Bootstrap分析
/** * Bootstrap loader for Catalina. This application constructs a class loader * for use in loading ...
- wordcloud+jieba
Wordcloud各参数含义 font_path : string #字体路径,需要展现什么字体就把该字体路径+后缀名写上,如:font_path = '黑体.ttf' width : int (de ...
- xgboost使用
xgboost的实现方式为多颗CART树,其实xgboost就是类似于随机森林,但是与随机森林不同,他不是多个子树决策的结果,CART树最后会算出一个得分,是一个值,最后算出分类的时候,是多个值结合在 ...
- 面试:http协议
转自:http://www.cnblogs.com/ranyonsue/p/5984001.html#undefined HTTP简介 HTTP协议是Hyper Text Transfer Proto ...