Codeforces 451C Predict Outcome of the Game(暴力)
来源:互联网 发布:如何修改淘宝店铺域名 编辑:程序博客网 时间:2024/06/05 01:09
题目连接:Codeforces 451C Predict Outcome of the Game
题目大意:题意有点坑,就是三支球队有n场比赛,错过了k场,即这k场比赛不知道输赢,只知道第一支球队和第二支球队胜局情况差d1,第二和第三差d2,问说最后有没有可能三支队伍胜局数相同。
解题思路:考虑四种情况下的场数u,是否为3的倍数,u/3后是否比当前情况下胜局数最高的队伍大,并且还要判断该情况是否可行。
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;ll n, k, d1, d2;bool check (ll u, ll t) { if (u % 3 || u > n) return false; return u / 3 >= t;}bool judge () { if (n % 3) return false; /* */ if (check(n - k + d1 + d2 * 2, d1 + d2)) return true; if (check(n - k + 2 * d1 + d2, d1 + d2)) return true; if (check(n - k + d1 + d2, max(d1, d2))) return true; if (check(n - k + 2 * max(d1, d2) - min(d1, d2), max(d1, d2))) return true; return false;}int main () { int cas; scanf("%d", &cas); for (int i = 0; i < cas; i++) { scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2); printf("%s\n", judge() ? "yes" : "no"); } return 0;}
1 0
- Codeforces 451C Predict Outcome of the Game(暴力)
- codeforces--C. Predict Outcome of the Game
- Codeforces 451C Predict Outcome of the Game
- CodeForces 451 C. Predict Outcome of the Game
- Codeforces 451C. Predict Outcome of the Game
- Codeforces 451C Predict Outcome of the Game (枚举+YY)
- 451 C. Predict Outcome of the Game
- 451C - Predict Outcome of the Game
- Codeforces #258 (Div. 2) C. Predict Outcome of the Game
- codeforces 258(Div.2) C. Predict Outcome of the Game
- Codeforces Div. 2 #258-C. Predict Outcome of the Game
- CF 451 C Predict Outcome of the Game(数学题)
- Codeforces Round #258 (Div. 2) C - Predict Outcome of the Game
- Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game
- Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game
- Codeforces Round #258 (Div. 2/C)/Codeforces451C_Predict Outcome of the Game(枚举)
- Game Outcome CodeForces
- CodeForces 157A Game Outcome
- LeetCode OJ算法题(三十一):Longest Valid Parentheses
- PHP转换文件夹下所有文件编码的实现代码(转)
- Eclipse 新建PHP工程教程
- C++中的纯虚函数
- 暑期个人赛--第二场--D--every SG(重)
- Codeforces 451C Predict Outcome of the Game(暴力)
- Linux TCP/UDP小例子
- Spring和Hibernate集成的HibernateTemplate的一些常用方法总结
- OpenCV的三帧差法
- 重载(overload)、覆盖(override)、隐藏(hide)的区别
- HD 2013 蟠桃记
- rman做异机迁移
- VF
- Codeforces Round #166 (Div. 2) D. Good Substrings 罕见的哈希冲突