【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 ...
随机推荐
- 利用formdata对象上传文件时,需要添加的参数
function doUpload() { var formData = new FormData($( "#uploadForm" )[0]); $.ajax({ url: 'h ...
- ArcGIS在线帮助的使用指南
一直感觉ArcGIS的在线帮助就是鸡肋,没想到网络常见的所谓的高大上的博文,也不过是对GIS 在线帮助的拷贝,或者简单修改而已.其实ArcGIS的在线帮助包含了以下几个很好用的模块: 备注 ArcGI ...
- Android Mvvm模式的理解
1. Mvvm是什么,Mvvm是怎么来的?Mvvm模式广泛应用在WPF项目开发中,使用此模式可以把UI和业务逻辑分离开,使UI设计人员和业务逻辑人员能够分工明确. Mvvm模式是根据MVP模式来的,可 ...
- ds1302模块的一个arduino程序
/* * 读写DS1302 时钟芯片 * @author Yangtf * 很棒的文档 http://www.21ic.com/jichuzhishi/datasheet/DS1302/data/18 ...
- springmvc hibernate整合
今天复习一下SpringMVC+Hibernate的搭建,本来想着将Spring-Security权限控制框架也映入其中的,但是发现内容太多 了,Spring-Security的就留在下一篇吧,这篇主 ...
- springMVC easyUI filebox 单个文件上传
被这个文件上传坑到如今.还是自己技术问题,照着之前extjs项目那边的上传实例,愣是上传不了 到后面就查了下springMVC的文件上传,依照那样搞定了http://blog.csdn.net/jad ...
- WebClient 请求返回的是Gbk编码解决方案
WebClient client = new WebClient(); client.Headers.Clear(); client.Hea ...
- u-boot分析1:Nandflash、Norflash启动
了解u-boot之前首先了解下Bootloader,简单说Bootloader就是一段小程序,它在系统上电时开始运行,初始化硬件设备,准备好软件环境,最后调用操作系统内核. u-boot全称:Univ ...
- 【转载】zookeeper数据模型
[转载请注明作者和原文链接, 如有谬误, 欢迎在评论中指正. ] ZooKeeper的数据结构, 与普通的文件系统极为类似. 见下图: 图片引用自developerworks 图中的每个节点称为一个 ...
- js进阶课程 12-9 jquery的事件对象event的方法有哪些?
js进阶课程 12-9 jquery的事件对象event的方法有哪些? 一.总结 一句话总结:三组六个,阻止默认事件一组,阻止冒泡一组,阻止冒泡和剩余事件一组. 1.事件的默认动作指什么? 比如点a标 ...