zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    初窥AndroidPlot(一)
    Android Studio安装、配置
    Android SDK Android NDK Android Studio 官方下载地址及方式
    学习Android图表绘制
    ActionBar研究(二)
    获取Android版本信息和程序版本号
    Android手机获取通话记录和短信记录
    Android开发之监听或获取手机短信内容【转】
    android 几种发送短信的方法【转】
    android开源框架android-async-http
  • 原文地址:https://www.cnblogs.com/moomcake/p/8686982.html
Copyright © 2011-2022 走看看