【题目链接】: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. C#正则表达式匹配HTML中的图片路径,图片地址

    C#正则表达式匹配HTML中的图片路径,图片地址 最近的项目中有个关于网页取图的功能需要我自己开发,那就是用正则表达式来匹配图片标签.       一般来说一个 HTML 文档有很多标签,比如“< ...

  2. Spring Profiles example--转载

    原文地址:http://www.mkyong.com/spring/spring-profiles-example/ Spring @Profile allow developers to regis ...

  3. eclipse 使用jetty调试时,加依赖工程的源码调试方法

    [1] 添加source eclipse-->debug as-->debug configurations-->source [2]若source不起作用 重新编译一下,mvn c ...

  4. POJ 3061 Subsequence 二分或者尺取法

    http://poj.org/problem?id=3061 题目大意: 给定长度为n的整列整数a[0],a[1],--a[n-1],以及整数S,求出总和不小于S的连续子序列的长度的最小值. 思路: ...

  5. BP神经网络公式推导及实现(MNIST)

    BP神经网络的基础介绍见:http://blog.csdn.net/fengbingchun/article/details/50274471,这里主要以公式推导为主. BP神经网络又称为误差反向传播 ...

  6. Oracle中暂时表空间的清理

    作者:iamlaosong Oracle暂时表空间主要用来做查询和存放一些缓冲区数据. 暂时表空间消耗的主要原因是须要对查询的中间结果进行排序.暂时表空间的主要作用: 索引create或rebuild ...

  7. Leetcode 第 2 题(Add Two Numbers)

    Leetcode 第 2 题(Add Two Numbers) 题目例如以下: Question You are given two linked lists representing two non ...

  8. php实现 字符串分割

    php实现 字符串分割 一.总结 一句话总结: 1.字符串按固定位分割函数是什么? 7 $str_arr=str_split($str,8); 2.字符串填补函数的参数是什么? 10 $str_arr ...

  9. xxxyyy

    https://www.gaojinan.com/vps-o p e n v p n-china-telecom-unicom-mobile-mianliu-ml.html

  10. 怎样cp文件夹时忽略指定的文件夹和文件

    在备份ltedecoder程序时,须要把此文件夹拷由到bak文件夹下.但decoder文件夹下有个大文件,不须要备份,还有日志问题,也不须要备份,怎样实现呢?? 方法: cd /source-dir ...