zoukankan      html  css  js  c++  java
  • CodeForces765C

    C. Table Tennis Game 2

    time limit per test:2 seconds
    memory limit per test:512 megabytes
    input:standard input
    output:standard output

    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 ka 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.

     1 //2017-02-14
     2 #include <iostream>
     3 #include <cstdio>
     4 #include <cstring>
     5 
     6 using namespace std;
     7 
     8 int main()
     9 {
    10     long long k, a, b;
    11     while(cin>>k>>a>>b)
    12     {
    13         long long ans = a/k+b/k;
    14         if(ans == 0 && a+b > 0)cout<<"-1"<<endl;
    15         else if(a < k && b%k != 0)cout<<"-1"<<endl;
    16         else if(b < k && a%k != 0)cout<<"-1"<<endl;
    17         else cout<<ans<<endl;
    18     }
    19 
    20     return 0;
    21 }
  • 相关阅读:
    kubernetes 修改 可用端口号
    解决Mac下MX4手机无法连接adb问题之解决方案
    由于源码使用是cc++与oc混编导致Unknown type name 'NSString'
    Cocos2dx使用wxsqlite开源加密SQLite3数据库
    Cocos2dx网络读取图片
    解决Xcode删除文件后missing file警告
    WebRTC 配置环境
    Cocos2d-x 3.0 纹理
    Mac/Linux如何查找应用所安装路径
    设置Git用户信息
  • 原文地址:https://www.cnblogs.com/Penn000/p/6399391.html
Copyright © 2011-2022 走看看