Description

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.

Sample Input

 题解:每一轮系列赛若要完成胜出的一方需要达到k分。此题分为两种情况:(1)a<k&&b<k;(2)c=max(a,b),c%k!=0&&min(a,b)<k输出-1,其他情况输出a/k+b/k;

(Input
11 11 5
Output
1
 #include <iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
using namespace std;
int main()
{
int i,j,n,ans=,t,k,ans1=,m,b,a;
scanf("%d%d%d",&a,&b,&n);
m=n>b?n:b;
k=n>b?b:n;
ans=m/a;
ans1=k/a;
if((ans==&&ans1==))
printf("-1\n");
else
{ if(m%a!=&&k<a)
printf("-1\n");
else
printf("%d\n",ans+ans1);
}
return ;
}

Table Tennis Game 2的更多相关文章

  1. PAT 1026. Table Tennis

    A table tennis club has N tables available to the public.  The tables are numbered from 1 to N.  For ...

  2. 1026. Table Tennis (30)

    题目如下: A table tennis club has N tables available to the public. The tables are numbered from 1 to N. ...

  3. PAT A1026 Table Tennis (30 分)——队列

    A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For a ...

  4. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C. Table Tennis Game 2 水题

    C. Table Tennis Game 2 题目连接: http://codeforces.com/contest/765/problem/C Description Misha and Vanya ...

  5. PAT 1026 Table Tennis[比较难]

    1026 Table Tennis (30)(30 分) A table tennis club has N tables available to the public. The tables ar ...

  6. 443 B. Table Tennis

    http://codeforces.com/contest/879/problem/B n people are standing in a line to play table tennis. At ...

  7. Table Tennis Game 2(找规律)

    Description Misha and Vanya have played several table tennis sets. Each set consists of several serv ...

  8. PAT甲级1026. Table Tennis

    PAT甲级1026. Table Tennis 题意: 乒乓球俱乐部有N张桌子供公众使用.表的编号从1到N.对于任何一对玩家,如果有一些表在到达时打开,它们将被分配给具有最小数字的可用表.如果所有的表 ...

  9. PAT 甲级 1026 Table Tennis(模拟)

    1026. Table Tennis (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A table ...

  10. PAT 1026 Table Tennis (30)

    A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For a ...

随机推荐

  1. 图解MySQL 内连接、外连接、左连接、右连接、全连接

    用两个表(a_table.b_table),关联字段a_table.a_id和b_table.b_id来演示一下MySQL的内连接.外连接( 左(外)连接.右(外)连接.全(外)连接). MySQL版 ...

  2. 【Codeforces】894D. Ralph And His Tour in Binary Country 思维+二分

    题意 给定一棵$n$个节点完全二叉树,$m$次询问,每次询问从$a$节点到其它所有节点(包括自身)的距离$L$与给定$H_a$之差$H_a-L$大于$0$的值之和 对整棵树从叶子节点到父节点从上往下预 ...

  3. Solr初步使用

    参考此文:https://blog.csdn.net/frankcheng5143/article/details/71159936

  4. [QT] Tab键切换焦点顺序

    在Qt Designer 中点击“编辑Tab顺序“按钮进入编辑Tab顺序模式,如下图: 之后界面会变成这样: 随处点击右键即可弹出菜单,选择  "制表符顺序列表..." 出现 剩下 ...

  5. 【解题报告】牡丹江现场赛之ABDIK ZOJ 3819 3820 3822 3827 3829

    那天在机房做的同步赛,比现场赛要慢了一小时开始,直播那边已经可以看到榜了,所以上来就知道A和I是水题,当时机房电脑出了点问题,就慢了好几分钟,12分钟才A掉第一题... A.Average Score ...

  6. HihoCoder 1121 二分图一•二分图判定

    二分图一•二分图判定 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 大家好,我是小Hi和小Ho的小伙伴Nettle,从这个星期开始由我来完成我们的Weekly. 新年回 ...

  7. np基本函数大全

    Numpy是科学计算库,是一个强大的N维数组对象ndarray,是广播功能函数.其整合C/C++.fortran代码的工具 ,更是Scipy.Pandas等的基础 .ndim :维度 .shape : ...

  8. 使用Gson轻松解决复杂结构的Json数据解析

    转载请注明来源: http://blog.csdn.net/kjunchen/article/details/50961803 JSON简介 JSON(JavaScript Object Notati ...

  9. Spring aop 简单示例

    简单的记录一下spring aop的一个示例 基于两种配置方式: 基于xml配置 基于注解配置 这个例子是模拟对数据库的更改操作添加事物 其实并没有添加,只是简单的输出了一下记录 首先看下整个例子的目 ...

  10. 对Servlet规范的蜻蜓点水

    现在我们大家基本都用struts或springmvc进行java web的开发,但我们都知道java web的核心技术是jsp servlet javabean的组合.因此很有必要知道servlet规 ...