【题目链接】: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的更多相关文章

  1. 【Codeforces 478C】Table Decorations

    [链接] 我是链接,点我呀:) [题意] 给你r,g,b三种颜色的气球 每张桌子要放3个气球 但是3个气球的颜色不能全都一样 (允许两个一样,或者全都不一样) 问你最多能装饰多少张桌子 [题解] 先把 ...

  2. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  3. 【35.29%】【codeforces 557C】Arthur and Table

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【84.62%】【codeforces 552A】Vanya and Table

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【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 ...

  6. 【Codeforces 582A】 GCD Table

    [题目链接] 点击打开链接 [算法] G中最大的数一定也是a中最大的数.          G中次大的数一定也是a中次大的数. 第三.第四可能是由最大和次大的gcd产生的 那么就不难想到下面的算法: ...

  7. 【77.78%】【codeforces 625C】K-special Tables

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  8. 【codeforces 760A】Petr and a calendar

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【codeforces 758C】Unfair Poll

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. GO语言学习(十八)Go 语言接口

    Go 语言接口 Go 语言提供了另外一种数据类型即接口,它把所有的具有共性的方法定义在一起,任何其他类型只要实现了这些方法就是实现了这个接口. 实例 /* 定义接口 */ type interface ...

  2. java hadoop file system API

    org.apache.hadoop.fs Class FileSystem java.lang.Object org.apache.hadoop.fs.FileSystem All Implement ...

  3. HTTP网络协议(三)

    HTTP首部字段有四种类型:通用首部字段,请求首部字段,响应首部字段,实体首部字段.  通用首部字段: 首部字段 说明 Cache-Control 控制缓存的行为 Connection 逐跳首部.连接 ...

  4. UML学习总结(1)——UML学习入门

    随着亲手接触的项目越来越多,项目的复杂度越来越大,项目的理解程度也变的很难,尤其是在接收一个别人已经做好的项目时,你迫切先想到的就是"有没有文档啊",当然是各种文档,概要设计文档, ...

  5. ehcache、memcache、redis三大缓存比较(转)

    最近项目组有用到这三个缓存,去各自的官方看了下,觉得还真的各有千秋!今天特意归纳下各个缓存的优缺点,仅供参考!  Ehcache 在Java项目广泛的使用.它是一个开源的.设计于提高在数据从RDBMS ...

  6. SpringMVC学习记录(五)--表单标签

    在使用SpringMVC的时候我们能够使用Spring封装的一系列表单标签,这些标签都能够訪问到ModelMap中的内容. 以下将对这些标签一一介绍. 1.引入标签头文件 在正式介绍SpringMVC ...

  7. 开发板 视频1 05_01 05_02 05_03 关于ubuntu的一些操作

    ctrl+alt+T 打开中端 ctrl+d  退出 ctrl+alt+f1 到f6 进入dos中端 ctrl+alt+f7 是退出 05_02 启动root用户   也就是进入 前面出现root了 ...

  8. 从零开始使用git第一篇:下载安装配置

    从零开始使用git 第一篇:下载安装配置 第一篇:从零开始使用git第一篇:下载安装配置 第二篇:从零开始使用git第二篇:git实践操作 第三篇:从零开始使用git第三篇:git撤销操作.分支操作和 ...

  9. POJ 3169 Layout (HDU 3592) 差分约束

    http://poj.org/problem?id=3169 http://acm.hdu.edu.cn/showproblem.php?pid=3592 题目大意: 一些母牛按序号排成一条直线.有两 ...

  10. ios本地相册 照像 本地视频

    -(IBAction)btnClick{ UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate: ...