codeforces 258div2C Predict Outcome of the Game
题目链接: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的更多相关文章
- CodeForces 451C Predict Outcome of the Game
Predict Outcome of the Game Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &a ...
- codeforces 451C. Predict Outcome of the Game 解题报告
题目链接:http://codeforces.com/problemset/problem/451/C 题目意思:有3支球队(假设编号为1.2.3),总共要打 n 场比赛,已知已经错过这n场比赛中的 ...
- 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 ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
- CodeForces 157A Game Outcome
A. Game Outcome time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- 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三队赢的场次的关系 ...
- Codeforces Round #258 (Div. 2)[ABCD]
Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...
- cf451C-Predict Outcome of the Game
http://codeforces.com/problemset/problem/451/C A - Predict Outcome of the Game Time Limit:2000MS ...
- Codeforces Round #258 (Div. 2)
A - Game With Sticks 题目的意思: n个水平条,m个竖直条,组成网格,每次删除交点所在的行和列,两个人轮流删除,直到最后没有交点为止,最后不能再删除的人将输掉 解题思路: 每次删除 ...
随机推荐
- 两个简单的Loading
置顶文章:<纯CSS打造银色MacBook Air(完整版)> 上一篇:<JavaScript并非"按值传递"> 作者主页:myvin 博主QQ:85139 ...
- IE8/9的console之坑
这几天遇到个深坑,在改别人代码时,发现ajax在ie8下请求不成功.清理了缓存后,可以请求成功!(清理缓存只是表象而已,后文说原因) 后来慢慢看代码,发现ajax成功回调了!在success回调里,我 ...
- 常见面试题之ListView的复用及如何优化
经常有人问我,作为刚毕业的要去面试,关于安卓开发的问题,技术面试官会经常问哪些问题呢?我想来想去不能一股脑的全写出来,我准备把这些问题单独拿出来写,并详细的分析一下,这样对于初学者是最有帮助的.这次的 ...
- angular的工具方法笔记(equals, HashKey)
分别是angular脏值检测的工具方法equals和 类HashKey的使用方法 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transi ...
- Beta项目冲刺汇总贴
第一天 http://www.cnblogs.com/Allenbi/p/5003704.html 第二天 http://www.cnblogs.com/Allenbi/p/5020820.html ...
- 3.3.1实现Servlet
FirstServlet.java package com.helloweenvsfei.servlet; import java.io.IOException; import java.io.Pri ...
- poj 3669 线段树成段更新+区间合并
添加 lsum[ ] , rsum[ ] , msum[ ] 来记录从左到右的区间,从右到左的区间和最大的区间: #include<stdio.h> #define lson l,m,rt ...
- Java 关键字 native
native 关键字说明其修饰的方法是一个原生态方法,方法对应的实现不是在当前文件中,而是在用其他语言实现的文件中.Java语言本身不能对操作系统底层进行访问和操作,但是可以通过JNI接口调用其他语言 ...
- Java-对象池
对象池使用的基本思路是:将用过的对象保存起来,等下一次需要这种对象的时候,再拿出来重复使用,从而在一定程度上减少频繁创建对象所造成的开销. 并非所有对象都适合拿来池化――因为维护对象池也要造成一定开销 ...
- jsp学习(四)
JavaBean是一个可重复使用的软件组件,是遵循一定标准.用java语言编写的一个类,该类的一个实例称为一个JavaBean,简称bean. 它必须符合如下规范:1.必须有一个零参数的默认构造函数2 ...