题目链接: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. OOP多态和继承要点

         早期绑定和多态 C#函数重载的签名规则是用参数的类型和数量判断,而不是函数的名字. 函数返回值不作为重载签名. 修饰符不作为签名的一部分,如static 同函数中,多个参数名称要唯一 ref ...

  2. Android的开发环境的发展演变

    1.Android的开发环境: 之前大家都是安装eclipse,然后再下载安装sdk等插件,还需要配置比较麻烦.不过2013年,有了新的选择,在I/O大会上,谷歌推出新的Android开发环境——An ...

  3. WCF调用时提示错误 "已尝试创建到达不支持 .Net 框架的服务的通道。可能遇到 HTTP 终结点"

    一个以前运行的很正常的项目,某天突然无法连接WCF构建的后台.使用WCFTestClient连接到服务是正常的,但是调用服务中的方式时就报出了以下错误: 已尝试创建到达不支持 .Net 框架的服务的通 ...

  4. java.lang.NoClassDefFoundError: javax/transaction/UserTransaction

    在运行定时任务的时候报错: Java.lang.NoClassDefFoundError: javax/transaction/UserTransaction 原因:缺少jta的jar包 解决方法:下 ...

  5. python学习笔记4(对象/引用;多范式; 上下文管理器)

    ### Python的强大很大一部分原因在于,它提供有很多已经写好的,可以现成用的对象 21. 动态类型:对象/引用 对象和引用: 对象是储存在内存中的实体,对象名只是指向这一对象的引用(refere ...

  6. 洛谷P2726 阶乘 Factorials

    题目背景 N的阶乘写作N!,表示小于等于N的所有正整数的乘积. 题目描述 阶乘会变大得很快,如13!就必须用32位整数类型来存储,到了70!即使用浮点数也存不下了. 你的任务是找到阶乘最前面的非零位. ...

  7. jsp学习(三)

    <%@page contentType="text/html;charset=gbk"%> <html> <body> <font siz ...

  8. hihocoder #1034 毁灭者问题

    传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在 Warcraft III 之冰封王座中,毁灭者是不死族打三本后期时的一个魔法飞行单位. 毁灭者的核心技能之一, ...

  9. android button 函数调用栈

    Button button=(Button) findViewById(R.id.button);button.setOnClickListener(new Button.OnClickListene ...

  10. linux学习笔记一----------文件相关操作

    一.目录结构 二.文件管理操作命令(有关文件夹操作,使用Tab键自动补全文件名(如果多个默认第一个)) 1.ls 查看目录信息:ls -l 查看目录详细信息(等价于ll 某些系统不支持) 2.pwd ...