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
题目:
2 seconds
512 megabytes
standard input
standard output
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 ≤ 109, 0 ≤ a, b ≤ 109, 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
Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
题意:题意好迷,做题靠枚举题意。
题目说的是两人在打比赛,每场比赛有很多轮,每轮获胜的选手可以得一分。如果在某一场比赛中某人的分达到了k分,则这场比赛结束,然后重开一场比赛。
现在给出两人比赛后总得分a,b,问你这种得分是否合法(即能否在x场比赛后出现这种得分),如果合法,输出最大的x
思路:
要求最大的x,贪心的选取每场比分为0:k或k:0时,比分最大。
如果a%k或b%k不等于0,那么可以用某一场比赛消耗掉这些余数。
所以不合法的情况就是这些余数消耗不掉。
#include <bits/stdc++.h> using namespace std; #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double pi=acos(-1.0);
const int K=1e5+;
const int mod=1e9+; int k,a,b,ans; int main(void)
{
cin>>k>>a>>b;
ans=a/k+b/k;
if(a%k!= && b/k==) ans=-;
if(b%k!= && a/k==) ans=-;
printf("%d\n",ans);
return ;
}
Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C - Table Tennis Game 2的更多相关文章
- 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 ...
 - Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A B C D 水  模拟  构造
		
A. Neverending competitions time limit per test 2 seconds memory limit per test 512 megabytes input ...
 - Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined)  F. Souvenirs 线段树套set
		
F. Souvenirs 题目连接: http://codeforces.com/contest/765/problem/F Description Artsem is on vacation and ...
 - Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding 拓扑排序
		
E. Tree Folding 题目连接: http://codeforces.com/contest/765/problem/E Description Vanya wants to minimiz ...
 - Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) D. Artsem and Saunders 数学 构造
		
D. Artsem and Saunders 题目连接: http://codeforces.com/contest/765/problem/D Description Artsem has a fr ...
 - Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B. Code obfuscation 水题
		
B. Code obfuscation 题目连接: http://codeforces.com/contest/765/problem/B Description Kostya likes Codef ...
 - Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A. Neverending competitions 水题
		
A. Neverending competitions 题目连接: http://codeforces.com/contest/765/problem/A Description There are ...
 - Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) E. Tree Folding
		
地址:http://codeforces.com/contest/765/problem/E 题目: E. Tree Folding time limit per test 2 seconds mem ...
 - Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) D. Artsem and Saunders
		
地址:http://codeforces.com/contest/765/problem/D 题目: D. Artsem and Saunders time limit per test 2 seco ...
 
随机推荐
- easyui menu 添加hideItem/showItem 方法
			
$.extend($.fn.menu.methods,{ showItem:function(jq,text){ return jq.each(function(){ var item = $(thi ...
 - Easyui Datagrid的Rownumber行号显示问题
			
Datagrid中当你的行数据超过9999时,第一列的行号rownumber将会因为表格内容过长而导致无法显示全部数字, 这一点Easyui无法做到自适应 所以需要进行修改,这里扩展一个方法就行了. ...
 - 描述J2EE框架的多层结构,并简要说明各层的作用。
			
描述J2EE框架的多层结构,并简要说明各层的作用. 解答: 1) Presentation layer(表示层) a. 表示逻辑(生成界面代码) b. 接收请求 c. 处理业务层抛出的异常 d. 负责 ...
 - 【vijos】1770 大内密探(树形dp+计数)
			
https://vijos.org/p/1770 不重不漏地设计状态才能正确的计数QAQ 虽然可能最优化是正确的,但是不能保证状态不相交就是作死.... 之前设的状态错了... 应该设 f[i][0] ...
 - 在ChemDraw中一键隐藏所有氢原子的方法
			
在常见的化学结构中氢原子是非常常见的一种原子,而且在很多的结构中氢原子的数量是非常的多的.因此我们在使用ChemDraw化学绘图软件绘制化学结构的过程中,发现有的时候氢原子数量过多会影响到整体结构的美 ...
 - Python入门(六):标准库
			
操作系统接口 os模块提供了不少与操作系统相关联的函数. import os os.getcwd() # 返回当前的工作目录 os.chdir('d:/') # 修改当前的工作目录 os.system ...
 - TypeScript 变量声明(二)
			
ES6 中,变量声明一共有6种,分别是var.function .let.const.class和import. let 基本语法:let 变量名 :类型.其中类型不是必须的. 1.用于声明变量,其用 ...
 - 在ubuntu机器上部署php测试环境
			
在ubuntu机器上部署php测试环境 一.部署环境 Ubuntu11.10_X86_32,编译安装相应的软件:nginx+mysql+php. 二.软件安装 2.1 软件下载 libiconv-1. ...
 - iOS 如何在一个应用程序中调用另一个应用程序
			
原则上iOS的沙箱原理,是阻止一个app去访问其他app的资源乃至是系统底层的资源的但是我们可以通过一种变相的方式:通过对应的URL模式和其他程序进行通讯. iOS应用之间的调用步骤: 一, 调用自己 ...
 - Entity Framework查询生成大量的子查询,如何避免?求救
			
最近使用Entity Framework做一个中型的项目,一张表含有千万条数据,并没有使用很复杂的查询,只是程序上使用了DTO进行帅选数据,且使用了分页,效果很不理想.经过跟踪sql,我发现很多简单的 ...