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个竖直条,组成网格,每次删除交点所在的行和列,两个人轮流删除,直到最后没有交点为止,最后不能再删除的人将输掉 解题思路: 每次删除 ...
随机推荐
- Node服务一键离线部署
背景说明 项目测试通过,到了上线部署阶段.部署的机器安全限制比较严格,不允许访问外网.此外,没有对外网开放ssh服务,无法通过ssh远程操作. 针对上面提到的两条限制条件,通过下面方式解决: 无法访问 ...
- MVVM开源框架Knot.js 教程2 - 大幅改变前端框架开发体验的Debugger
Knotjs教程系列 1.CBS初步 2.Knot.js Debugger(本文) ....持续增加中 Knot.js 教程2 - 改变前端框架开发体验的Debugger Debugger只是一个方便 ...
- -webkit-overflow-scrolling:touch iosBug
IOS8+ -webkit-overflow-scrolling:touch 会导致webview崩溃 解决方案 用js动态添加样式 比如: $("body").css(&qu ...
- EF保存平面数据到SqlServer
前言 公司开展一个项目,需要根据客户手机定位获取周围内的精准广告,具体是管理员在地图上绘制多边形的广告范围,落在范围内的客户就看到此广告.下面将我的实现方法简单叙述一下,以供有相同需求的朋友参考. E ...
- css基本的东西
0 css本来也是一个比较乱的东西,我们需要在最恰当的情况下,写出最杂乱的效果.1 面对body设置了 -webkit-font-smoothing:antialiased (默认值为subpixel ...
- angular_$attrs
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- JQuery学习(2)之Ajax
同步传输 正 多件事情一起做 | 程 不 事情一件一件地做 常: | 序 是: 异步传输 人 事情一件一件地做 | 员 人 多件事情可以一起做 附加(XML) ★XML作用:用来存储数据. ★XML特 ...
- oracle-分页查询方案
一.使用rownum做三层包装查询(常用方案) SELECT * FROM ( SELECT A.*, ROWNUM RN FROM (SELECT * FROM TABLE_NAME) A ) 其中 ...
- 35.Android之带删除按钮EditText学习
今天实现Android里自定义带删除功能的EditText,效果如下: 当输入内容时,EditText变为带有一个删除功能按钮的编辑框,如图: 实现代码很简单,直接上代码, 布局文件xml: < ...
- 【BZOJ-2295】我爱你啊 暴力
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 202 Solved: 141[Submit][St ...