CF765C Table Tennis Game 2

题意:

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?≤?1e9, 0?≤?a,?b?≤?1e9, 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

思路:

数学题。

实现:

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4
 5 int k, a, b;
 6 int main()
 7 {
 8     cin >> k >> a >> b;
 9     if (a < k && b % k || b < k && a % k)
10         puts("-1");
11     else
12         cout << a / k + b / k << endl;
13     return 0;
14 }
时间: 2024-10-15 06:03:48

CF765C Table Tennis Game 2的相关文章

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

地址:http://codeforces.com/contest/765/problem/C 题目: 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 co

1026. Table Tennis (30)

A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the smallest number. If all the

浙大 PAT Advanced level 1026. Table Tennis (30)

A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the smallest number. If all the

Pat(Advanced Level)Practice--1026(Table Tennis)

Pat1026代码 题目描写叙述: A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the smallest n

@@443 B. Table Tennis

n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone win

1026 Table Tennis (30 分)

1026 Table Tennis (30 分) A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the sma

PAT甲级1026 Table Tennis【模拟好题】

题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805472333250560 题意: 有k张乒乓球桌,有的是vip桌.有n对玩家来打乒乓,有的玩家是VIP玩家. 当他们到达时,如果没有空桌子他们就排队等待. 这时候如果有VIP桌子空出来了,那么就优先给队列里的VIP玩家,如果没有VIP玩家就给普通玩家. 如果普通桌子空出来了,就给队列里排在最前的玩家. 如果玩家到达的时候有好多桌子可以选择,那么他会选择桌号最小的

PAT (Advanced Level) 1026. Table Tennis (30)

情况比较多的模拟题. 交了50发的样子才AC......AC之后我的天空星星都亮了. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<map> #include<queue> #include<vector> using namespace std; struct

1795. Table tennis

#include<iostream>#include<cmath> using namespace std;int main(){ int n; cin>>n; while(n--){  int t;  cin>>t;  int points=0;  while(t--){   int a,b;   cin>>a>>b;   if((a>10&&a<50)&&(b>10&&am