题目链接: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. http请求过程简要

    一次http请求主要分为3个大步. 建立tcp连接. 这里就发生了经典的tcp三次握手.做个类比解释下,tcp好比http的秘书,和厂家(服务器端)做买卖.老板(http)叫秘书(tcp)去联系一下, ...

  2. ssh 返回错误 Too many authentic authentication failures for root 的时候检查 ssh 配置

    路径 cd /etc/ssh ls -ltr sudo vi sshd_config 改为以下内容(yes): PermitRootLogin yes

  3. JS中decodeURI()与decodeURIComponent()区别

    decodeURI()定义和用法:decodeURI() 函数可对 encodeURI() 函数编码过的URI 进行解码. 语法:decodeURI(URIstring) 参数 描述:URIstrin ...

  4. C#基础知识系列一(goto、i++、三元运算符、ref和out、String和string、重载运算符)

    前言 这两天在网上看到的总结很多,尤其是博客园中的,很多很多,也给了我很多的启发,当然自己也总结过,而且有很多人也给与我一些意见和看法.不管怎样,自己还是先把所谓的基础知识加强巩固下吧. 2014年的 ...

  5. [c#基础]堆和栈

    前言 堆与栈对于理解.NET中的内存管理.垃圾回收.错误和异常.调试与日志有很大的帮助.垃圾回收的机制使程序员从复杂的内存管理中解脱出来,虽然绝大多数的C#程序并不需要程序员手动管理内存,但这并不代表 ...

  6. PS转换图片——我教你

    将图片转换为web格式所有格式,选png8 或者gif 16位

  7. 在Oracle里,表的别名不能用as,列的别名可以用as

    列的别名也可以不用as,如:select t.a xxx from table t 在Oracle数据库中,数据表别名是不能加as的,例如: select a.appname from appinfo ...

  8. 全局唯一标识符(GUID)

    全局唯一标识符,简称GUID(发音为/ˈɡuːɪd/或/ˈɡwɪd/),是一种由算法生成的唯一标识,通常表示成32个16进制数字(0-9,A-F)组成的字符串,如:{21EC2020-3AEA-106 ...

  9. unicode和gbk的互相转换

    unicode和gbk的互相转换主要依靠window下的escape和unescape方法,然后把%u替换成\u就好了; var GB2312UnicodeConverter = { ToUnicod ...

  10. CODEVS 1258 关路灯

    写动归终于能不看题解一次A了!(其实交了两次,一次80一次A) 我练功发自真心! 题目描述 Description 多瑞卡得到了一份有趣而高薪的工作.每天早晨他必须关掉他所在村庄的街灯.所有的街灯都被 ...