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.
The first line contains three space-separated integers k, a and b (1 ≤ k ≤ 1e9, 0 ≤ a, b ≤ 1e9, a + b > 0).
If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets.
11 11 5
1
11 2 3
-1
思路:
数学题。
实现:
#include <iostream>
#include <cstdio>
using namespace std; int k, a, b;
int main()
{
cin >> k >> a >> b;
if (a < k && b % k || b < k && a % k)
puts("-1");
else
cout << a / k + b / k << endl;
return ;
}
CF765C Table Tennis Game 2的更多相关文章
- PAT 1026. Table Tennis
A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For ...
- 1026. Table Tennis (30)
题目如下: A table tennis club has N tables available to the public. The tables are numbered from 1 to N. ...
- 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 ...
- 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 ...
- PAT 1026 Table Tennis[比较难]
1026 Table Tennis (30)(30 分) A table tennis club has N tables available to the public. The tables ar ...
- 443 B. Table Tennis
http://codeforces.com/contest/879/problem/B n people are standing in a line to play table tennis. At ...
- Table Tennis Game 2(找规律)
Description Misha and Vanya have played several table tennis sets. Each set consists of several serv ...
- PAT甲级1026. Table Tennis
PAT甲级1026. Table Tennis 题意: 乒乓球俱乐部有N张桌子供公众使用.表的编号从1到N.对于任何一对玩家,如果有一些表在到达时打开,它们将被分配给具有最小数字的可用表.如果所有的表 ...
- PAT 甲级 1026 Table Tennis(模拟)
1026. Table Tennis (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A table ...
随机推荐
- stl里面的空间适配器
一般而言,如果频繁地向system heap申请和释放空间很小的内存空间块(小于128B的),就会对系统内存资源产生很多内存碎片(fragment)的问题,而C++的::operator new() ...
- asp.net微软图表控件MsChart
前段时间,开发项目时,由于需要,需要将一些数据统计,并以图表形式显示.由于是asp.net,所以就找到了MsChart图表控件,还是挺方便实用的,分享一下. MsChart控件的主要组成如图所示 工具 ...
- 机器学习 Hidden Markov Models 2
Hidden Markov Models 下面我们给出Hidden Markov Models(HMM)的定义,一个HMM包含以下几个要素: ∏=(πi)表示初始状态的向量.A={aij}状态转换矩阵 ...
- 聊聊Spring的核心组件
Spring的核心是IOC容器,它本质上是一个bean关系集合.而要实现它也是有beans,context,core三个模块完成的. beans包主要是负责bean的定义,创建和解析工作,里面用到了简 ...
- bzoj2337 XOR和路径——高斯消元
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2337 异或就一位一位考虑: x为到n的概率,解方程组即可: 考虑了n就各种蜜汁错误,所以索性 ...
- CMake命令之list
用途:提供一些列表操作 list(LENGTH <list><output variable>) list(GET <list> <elementindex ...
- mac下载模块时报错OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/chardet'
原文地址:https://www.cnblogs.com/liangyan-1989/p/8143129.html 安装完pip后,使用pip install selenium报以下错 OSError ...
- Vue.nextTick()的正确使用
Vue异步执行DOM更新.只要观察导数据变化,Vue将开启一个队列,并缓冲在同一事件循环中发生的所有数据改变,如果同一个watcher被多次触发,只会一次推入到队列中.这种在缓冲时去除重复数据对于避免 ...
- bzoj2384
树状数组+KMP 匹配问题上KMP 但是问题在于如何判断两个位置相等,我们认为如果一个位置之前比他小的数数量相同那么就是相等. 那么我们用树状数组动态维护这个东西,每次跳nxt的时候用树状数组删除数. ...
- C. Vanya and Scales
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...