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 ...
随机推荐
- vue 移动端开发
1.vue开发中的路由: 关于require 与import 的区别 2.vue中的mock数据 3.
- 基于Python 的简单推荐系统
def loadExData(): return[[1,1,1,0,0], [2,2,2,0,0], [1,1,1,0,0], [5,5,5,0,0], [1,1,0,2,2], [0,0,0,3,3 ...
- css盒子模型详解一
什么是CSS的盒子模式呢?为什么叫它是盒子?先说说我们在网页设计中常听的属性名:内容(content).填充(padding).边框(border).边界(margin), CSS盒子模式都具备这些属 ...
- vscode——配置终端集成bash和cmd
前言 配置后bash和cmd是集成的,输入bash回车则进入bash,输入cmd回车则进入cmd 步骤 首先肯定是需要打开我们的vscode咯~ 进入终端设置 配置shell路径 根据自己的系统来复制 ...
- javascript中基本类型和引用类型的区别分析
大多数人系统学习过的程序设计语言,在这些语言的学习过程中最早学到的几个要点之一就是值类型和引用类型的区别.下面我们来看一下在 JavaScript 中基本数据类型(Primitive Types)和引 ...
- 关闭ext4文件系统的日志功能
最近在帮一个研究生弄一个虚拟化环境下的基于Innodb的日志文件的读写优化的实验,实验的具体详细内容就不说了,其中有一个步骤需要将MySQL的日志文件放置在一块单独的硬盘里面,这块硬盘要么是ext2, ...
- mongodb c++ driver安装踩坑记
安装教程:https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/ (1) “initializer_list” fil ...
- 【POJ 1655】 Balancing Act
[题目链接] 点击打开链接 [算法] 树形DP求树的重心 [代码] #include <algorithm> #include <bitset> #include <cc ...
- javascript之表格节点操作
<html> <div class='add'> 名字: <input type="" name=""&g ...
- web.xml配置之<context-param>
<context-param>的作用和用法: 1.<context-param>配置是是一组键值对,比如: <context-param> <p ...