• Table Tennis Game 2


    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
     1 #include <iostream>
     2 #include<stdio.h>
     3 #include<string.h>
     4 #include<algorithm>
     5 #include<stack>
     6 #include<queue>
     7 #include<deque>
     8 using namespace std;
     9 int main()
    10 {
    11     int i,j,n,ans=0,t,k,ans1=0,m,b,a;
    12     scanf("%d%d%d",&a,&b,&n);
    13     m=n>b?n:b;
    14     k=n>b?b:n;
    15     ans=m/a;
    16     ans1=k/a;
    17     if((ans==0&&ans1==0))
    18         printf("-1
    ");
    19     else
    20     {
    21 
    22             if(m%a!=0&&k<a)
    23                 printf("-1
    ");
    24             else
    25                printf("%d
    ",ans+ans1);
    26     }
    27         return 0;
    28 }
  • 相关阅读:
    python ddt 传多个参数值示例
    Appium 输入 & 符号,实际输入&-
    curl 调用jenkins的api
    Android WebView的Js对象注入漏洞解决方案
    Could not find com.android.tools.build:gradle:1.3.0.
    react-native疑难
    win上搭建react-native android环境
    gradle大体内容
    android studio This client is too old to work with the working copy at
    sharedPreference
  • 原文地址:https://www.cnblogs.com/moomcake/p/8686982.html
Copyright © 2020-2023  润新知