题目链接:http://codeforces.com/contest/451/problem/C

解题报告:三个球队之间一共有n场比赛,现在已经进行了k场,不知道每个球队的胜场是多少,如三个球队的胜场分别为a,b,c,那么已知的是:

|a - b | = d1

|b -c | = d2

输入n,k,d1,d2,要你判断有没有可能让三个球队最后的胜场数相同。

只要分四种情况就可以求出a,b,c分别是多少,然后判断是不是满足:

n % 3 == 0

a,b,c都小于n / 3

a >= 0 && b >= 0 && c >= 0

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long INT;
INT n,k,d1,d2; int judge(INT a,INT b,INT c)
{
if(n % != ) return ;
if(a < || b < || c < ) return ;
if(a + b + c > k) return ;
INT temp = n / ;
if(a > temp || b > temp || c > temp) return ;
return ;
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lld%lld%lld%lld",&n,&k,&d1,&d2);
if(n % != )
{
printf("no\n");
continue;
}
int flag = ;
INT t = (k + * d1 + d2),a;
if(t % == )
{
a = t / ;
if(judge(a,a-d1,a-d1-d2)) flag = ;
}
t = (k + * d1 - d2);
if(t % == )
{
a = t / ;
if(judge(a,a-d1,a-d1+d2)) flag = ;
}
t = (k - * d1 + d2);
if(t % == )
{
a = t / ;
if(judge(a,a+d1,a+d1-d2)) flag = ;
}
t = (k - * d1 - d2);
if(t % == )
{
a = t / ;
if(judge(a,a+d1,a+d1+d2)) flag = ;
}
printf(flag? "yes\n":"no\n");
}
return ;
}

codeforces 258div2C Predict Outcome of the Game的更多相关文章

  1. CodeForces 451C Predict Outcome of the Game

    Predict Outcome of the Game Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &a ...

  2. codeforces 451C. Predict Outcome of the Game 解题报告

    题目链接:http://codeforces.com/problemset/problem/451/C 题目意思:有3支球队(假设编号为1.2.3),总共要打 n 场比赛,已知已经错过这n场比赛中的 ...

  3. Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题

    C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...

  4. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

  5. CodeForces 157A Game Outcome

    A. Game Outcome time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  6. Codeforces Round #258 (Div. 2/C)/Codeforces451C_Predict Outcome of the Game(枚举)

    解题报告 http://blog.csdn.net/juncoder/article/details/38102391 题意: n场比赛当中k场是没看过的,对于这k场比赛,a,b,c三队赢的场次的关系 ...

  7. Codeforces Round #258 (Div. 2)[ABCD]

    Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...

  8. cf451C-Predict Outcome of the Game

    http://codeforces.com/problemset/problem/451/C A - Predict Outcome of the Game Time Limit:2000MS     ...

  9. Codeforces Round #258 (Div. 2)

    A - Game With Sticks 题目的意思: n个水平条,m个竖直条,组成网格,每次删除交点所在的行和列,两个人轮流删除,直到最后没有交点为止,最后不能再删除的人将输掉 解题思路: 每次删除 ...

随机推荐

  1. #Linux学习笔记# Linux文件的所有者、群组和其他人

    1.关于所有者.群组和其他人 在Linux系统中,每个文件都具有User.Group和Others三种身份的权限配置.那这三种身份分别表示什么意思呢?配置这三种身份的权限有啥意义呢? (1)文件所有者 ...

  2. MongoDB驱动之Linq操作

    添加下面命名空间到您的程序中: using MongoDB.Driver.Linq; 声明一变量保存对集合的引用 var collection = database.GetCollection< ...

  3. java中的File类

    File类 java中的File类其实和文件并没有多大关系,它更像一个对文件路径描述的类.它即可以代表某个路径下的特定文件,也可以用来表示该路径的下的所有文件,所以我们不要被它的表象所迷惑.对文件的真 ...

  4. Sublime Text 3 Build 3065 All System CracKed By Hmily[LCG]

    Sublime Text 3 Build 3065 All System CracKed By Hmily[LCG] <ignore_js_op> 程序员文本编辑器 Sublime Tex ...

  5. iOS边练边学--多线程练习的多图片下载 以及 使用第三方框架(SDWebImage)的多图片下载

    一.自己实现多图片下载应该注意的问题 沙盒缓存的问题 程序缓存的问题 cell重复利用显示图片混乱的问题 -- 用户拖拽快,下载图片慢导致的 解决图片混乱引入NSOperation集合的问题 资源下载 ...

  6. HYSBZ 1269文本编辑器 splay

    比较基本的操作. #include<map> #include<queue> #include<stack> #include<cmath> #incl ...

  7. 【CodeForces 618C】Constellation

    题 Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars n ...

  8. poj 1006 中国剩余定理解同余方程

    其实画个图就明白了, 该问题就是求同余方程组的解: n+d≡p (mod 23) n+d≡e (mod 28) n+d≡i (mod 33) #include "iostream" ...

  9. Vijos1056 图形面积

    描述 桌面上放了N个平行于坐标轴的矩形,这N个矩形可能有互相覆盖的部分,求它们组成的图形的面积. 格式 输入格式 输入第一行为一个数N(1≤N≤100),表示矩形的数量.下面N行,每行四个整数,分别表 ...

  10. GCC、Makefile编程学习

    相关学习资料 http://gcc.gnu.org/ https://gcc.gnu.org/onlinedocs/ http://zh.wikipedia.org/zh/GCC http://blo ...