【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 ...
随机推荐
- JS学习笔记 - fgm练习 - 限制输入框的字符类型 正则 和 || 或运算符的运用 i++和++i
<script> window.onload = function(){ var aInp = document.getElementsByTagName('input'); var oS ...
- Sql Server 2014完全卸载
经历过好多次Sql server的安装与卸载,有时发现自己卸载的费时费力,单纯地卸载个软件就要吐血了,那么现在我觉得是时候整理一下了. 1.在运行中输入services.msc,然后找到所有跟Sql ...
- oracle 多行转多列查询
oracle 多行转多列查询 ---create table Fruit(id int,name varchar(20), Q1 int, Q2 int, Q3 int, Q4 int);inse ...
- vue使用(三)
本节目标:获取后端api数据 需求:一个按钮,点击之后将服务器上的数据获取到,并显示出来 方法一: 1. 准备工作, (1)安装官方插件 vuedemo02>npm install vue-re ...
- css函数——calc()和attr()
css也有函数?好吧,我孤陋寡闻了.这里记录一下学习情况. calc()函数 定义:用于动态计算长度值 支持版本:css3 运算符前后都需要保留一个空格,例如:width: calc(100% - 1 ...
- 【Codeforces Round #443 (Div. 2) A】Borya's Diagnosis
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟 [代码] #include <bits/stdc++.h> using namespace std; const ...
- 步步为营(十五)搜索(一)DFS 深度优先搜索
前方大坑预警! 先讲讲什么是搜索吧. 有一天你去一个果园摘梨子,果农告诉你.有一棵树上有一个金子做的梨子,找到就是你的,你该怎么找? 地图例如以下: S 0 0 0 0 0 0 0 0 0 0 0 0 ...
- Source Insight 3.50.0065使用详解
转自calvinlee1984 Subject:Source Insight3.50.0065使用详解 Date: 21-Oct-2011 By: Calvinlee1984@ ...
- 10.12 android输入系统_InputStage理论
android应用程序对输入系统的处理分为多个阶段,我们把这些阶段称为InputStage 理论处理流程: (1)activity发给window,如果window不能处理,再由activity处理; ...
- Win10系统如何设置所有程序默认以管理员身份运行?
原文:Win10系统如何设置所有程序默认以管理员身份运行? 在win10系统中有些用户发现一些程序只有使用管理员身份运行能才打开,这样的话就感觉会麻烦很多,那么有没有办法设置所有程序都默认以管理员身份 ...