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. LeetCode OJ:Add Digits(数字相加)

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  2. 发现的好东西——bitset

    先向各位大佬介绍一个水题 任何一个正整数都可以用2的幂次方表示.例如 137=2^7+2^3+2^0 同时约定方次用括号来表示,即a^b 可表示为a(b). 由此可知,137可表示为: 2(7)+2( ...

  3. 前端画图之iphoneSE主屏

    今天逛园子,无意间看到一个用div+css画的Macbook Air的博客,瞬间想到很久之前我也做过类似的事, 而且,当时写完之后,真的是成就感爆棚啊!我去开源中国上翻到了我当时贴的源码,当时是在手机 ...

  4. Java并发编程总结

    基础概念 1.什么是原子操作?在Java Concurrency API中有哪些原子类(atomic classes)?原子操作(atomic operation)意为"不可被中断的一个或一 ...

  5. 手把手教你怎么用ArcgisOnline发布地图服务

    Arcgis推出了Arcgis Online,但是大家都不知道这是个什么东西,怎么用这个东西,今天这篇文章手把手的教你如何使用Arcgisonline发布地图服务. 一.ArcgisOnline简介 ...

  6. CentOS修改系统的默认启动模式为命令号界面

    CentOS在安装桌面之后,将图形界面设置为默认模式,给PC内存带来较大压力,所以希望修改系统的默认启动模式为命令号界面,而不启动图形界面.方法如下: 1.以 root用户登录系统:或者 用su切换到 ...

  7. ResNet网络结构

    MSRA(微软亚洲研究院)何凯明团队的深度残差网络(Deep Residual Network)在2015年的ImageNet上取得冠军,该网络简称为ResNet(由算法Residual命名),层数达 ...

  8. DNS域名解析负载均衡

  9. python学习之多线程(一)

    引入线程包或者命名空间import threading 一:建立一个简单的线程程序 import time, threading def test():    print('thread %s is ...

  10. win2003从组策略关闭端口(445/135/137/138/139/3389等)教程

    一些恶劣的病毒会从某些端口入侵计算机,因此关闭某些用不到的而又具有高风险的端口就显得很有必要,是服务器管理员要做的基本的安全防范.本文将介绍win2003系统在组策略关闭某一个端口的教程,文章以关闭4 ...