【codeforces 765C】Table Tennis Game 2
【题目链接】:http://codeforces.com/contest/765/problem/C
【题意】
枚举游戏先拿到k分的人胜;
然后两个人一个人得了a分,一个人得了b分;
问你最多可能进行了多少场比赛;
(要求恰好完成);
【题解】
假设这些东西
t1 = a%k,t2 = b%k;
w1 = a/k,w2 = b/k;
如果w1和w2都是正数,那么双方都有赢;
则可以把余数都在对方赢的那一场里面用掉;
即t1放在对方赢的某一场里面(全部);
当然;
如果都恰好整除了,即t1和t2都为0;
则直接输出w1+w2;
这可以理解为对方赢的那些场次,输的一方都一分没得;
这里还有
w1>0但是w2==0的情况;
这里如果t1不为0的话,那么剩余的t1分就没办法分配了;
因为对方一场都没有赢…
注意这些后就不难写出程序了;
手慢只hack了一个人.
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
LL k,a,b;
int main()
{
//freopen("F:\\rush.txt","r",stdin);
rel(k),rel(a),rel(b);
LL t1 = a%k,t2 = b%k;
LL w1 = a/k,w2 = b/k;
if (a+b==0)
return puts("-1"),0;
if (t1==0 && t2==0)
{
cout << w1+w2;
return 0;
}
if (w1>0 && w2>0)
return cout << w1+w2,0;
if (w1>0 && w2==0)
{
if (t1==0)
return cout <<w1+w2,0;
else
return puts("-1"),0;
}
if (w1==0 && w2==0)
return puts("-1"),0;
if (w1==0 && w2>0)
{
if (t2==0)
return cout << w1+w2,0;
else
puts("-1"),0;
}
return 0;
}
【codeforces 765C】Table Tennis Game 2的更多相关文章
- 【Codeforces 478C】Table Decorations
[链接] 我是链接,点我呀:) [题意] 给你r,g,b三种颜色的气球 每张桌子要放3个气球 但是3个气球的颜色不能全都一样 (允许两个一样,或者全都不一样) 问你最多能装饰多少张桌子 [题解] 先把 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【35.29%】【codeforces 557C】Arthur and Table
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【84.62%】【codeforces 552A】Vanya and Table
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 509A】Maximum in Table
[题目链接]:http://codeforces.com/contest/509/problem/A [题意] 给你一个递推式f[i][j] = f[i-1][j]+f[i][j-1]; 让你求f[i ...
- 【Codeforces 582A】 GCD Table
[题目链接] 点击打开链接 [算法] G中最大的数一定也是a中最大的数. G中次大的数一定也是a中次大的数. 第三.第四可能是由最大和次大的gcd产生的 那么就不难想到下面的算法: ...
- 【77.78%】【codeforces 625C】K-special Tables
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 【codeforces 760A】Petr and a calendar
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 758C】Unfair Poll
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- 1.3 Quick Start中 Step 2: Start the server官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 2: Start the server Step : 启动服务 Kafka ...
- 【组件】微信小程序input搜索框的实现
开发小程序的过程,是一个学习知识,解决问题的过程,每当实现了一个需求,总会有很大的成就感,每天记录一个开发过程中的细节.实现效果如下: 官方参考链接:https://developers.weixin ...
- C# C++ 字符串传递
C# C++ 字符串传递 标签: c#c++bytestring测试c 2012-06-14 17:425707人阅读评论(3)收藏举报 分类: C#(11) 作者同类文章X C++(112) 作 ...
- amazeui学习笔记--js插件(UI增强)--警告框Alert
amazeui学习笔记--js插件(UI增强)--警告框Alert 一.总结 1.警告框基本样式:用am-alert声明div容器, <div class="am-alert" ...
- 14. Spring Boot MyBatis 连接数据库
转自:https://blog.csdn.net/catoop/article/details/50553714
- JS错误记录 - 记录上次登陆的用户名
<script> //步骤 1.submit => 用户名存进cookie 2. onload => 从cookie读取用户名 window.onload = function ...
- Linear to physical address translation with support for page attributes
Embodiments of the invention are generally directed to systems, methods, and apparatuses for linear ...
- HTML 5 中FileReader的使用
FileReader 接口主要用来把文件读入到内存中,而且读取文件里的数据.FileReader接口提供了一个异步API,使用该API能够在浏览器主线程中异步訪问文件系统 ,读取文件里的数据. Fil ...
- Maven 异常:Project configuration is not up-to-date with pom.xml解决方案
一.异常信息: 导入maven工程后,出现如下错误: Description Resource Path Location TypeProject configuration ...
- Android layer-list的属性和使用具体解释
Android layer-list的属性和使用具体解释.layer-list是用来多个图层堆叠显示的,借这个特性能够做一些特别的效果(比方:阴影.以下的效果等),也能够投机取巧. 1.代码片 < ...