Codeforces Round #258 (Div. 2)C(暴力枚举)
就枚举四种情况,哪种能行就是yes了。很简单,关键是写法,我写的又丑又长。。。看了zhanyl的写法顿时心生敬佩。写的干净利落,简直美如画。。。这是功力的体现!
以下是zhanyl的写法,转载在此以供学习:
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <tr1/unordered_set>
#include <tr1/unordered_map> using namespace std;
using namespace tr1; const int g[][]={{,},{,-},{-,},{-,-}}; long long n,k,d[],f[];
int t;
bool ans; int main(){
scanf("%d",&t);
while(t--){
scanf("%I64d%I64d%I64d%I64d",&n,&k,&d[],&d[]);
if(n%){
puts("no");
continue;
}
n=n/;
ans=false;
for(int i=;i<;i++)
if((k-g[i][]*d[]-g[i][]*d[])%==){
f[]=(k-g[i][]*d[]-g[i][]*d[])/;
f[]=f[]+g[i][]*d[];
f[]=f[]+g[i][]*d[];
if(f[]>=&&f[]>=&&f[]>=&&f[]<=n&&f[]<=n&&f[]<=n)ans=true;
}
if(ans)puts("yes");
else puts("no");
}
return ;
}
Codeforces Round #258 (Div. 2)C(暴力枚举)的更多相关文章
- Codeforces Round #253 (Div. 2)B(暴力枚举)
就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...
- Codeforces Round #258 (Div. 2)[ABCD]
Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...
- Codeforces Round #258 (Div. 2) 小结
A. Game With Sticks (451A) 水题一道,事实上无论你选取哪一个交叉点,结果都是行数列数都减一,那如今就是谁先减到行.列有一个为0,那么谁就赢了.因为Akshat先选,因此假设行 ...
- 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 ...
- 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 #426 (Div. 2)【A.枚举,B.思维,C,二分+数学】
A. The Useless Toy time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- Codeforces Round #258 (Div. 2) B. Sort the Array
题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把 ...
- Codeforces Round #258 (Div. 2) E. Devu and Flowers 容斥
E. Devu and Flowers 题目连接: http://codeforces.com/contest/451/problem/E Description Devu wants to deco ...
- Codeforces Round #258 (Div. 2) D. Count Good Substrings 水题
D. Count Good Substrings 题目连接: http://codeforces.com/contest/451/problem/D Description We call a str ...
随机推荐
- springMVC中使用 RequestBody 及 Ajax POST请求 415 (Unsupported Media Type)
使用POST请求的时候一直报错: Ajax 未设置 contentType 时会报 415 . 后台 RequestBody 承接前台参数,故对参数data的要求为“必传”“JSON”,否则会报40 ...
- Activity的生命周期整理
Activity主要的三种状态: Running(运行):在屏幕前台(位于当前任务堆栈的顶部) Paused(暂停):失去焦点但仍然对用户可见(覆盖Activity可能是透明或未完全遮挡) Stopp ...
- 【转】Linux下查看进程打开的文件句柄数
---查看系统默认的最大文件句柄数,系统默认是1024 # ulimit -n 1024 ----查看当前进程打开了多少句柄数 # lsof -n|awk '{print $2}'|sort|uniq ...
- 01_Hadoop学习笔记内容说明
Hadoop学习笔记内容说明_00 1. 观看云帆大数据梦琪老师的<企业级 Hadoop 1.x 应用开发基础课程>2014年4月左右版本. 2. 博客是在梦琪老师的随堂笔记上改动的, ...
- Nginx负载均衡案例
nginx负载均衡配置,windows版本和linux版本的nginx除了启动方式其他基本无差异. 1.Niginx安装 参考:https://www.cnblogs.com/zwcry/p/9454 ...
- 【转载】OPENWRT入门之四------openwrt命令行模式命令及其工具
连接来源http://bbs.xiaomi.cn/thread-9734746-1-1.html 需要学会用ssh登录路由器用linux命令查看.ps 命令查看当前系统运行的进程信息free 命令查看 ...
- Kubernetes busybox nslookup问题
使用最新版本的busybox会出现nslookup提示无法解析的问题: Server: 10.96.0.10 Address: 10.96.0.10:53 ** server can't find k ...
- 用javascript实现的验证码
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> ...
- Centos6.5下Hbase安装
下载 http://mirror.bit.edu.cn/apache/hbase/hbase-0.94.26/hbase-0.94.26.tar.gz 2. 解压 tar -zxvf hbase-0 ...
- 算法总结之 数组的partition调整
给定一个有序数组arr, 调整arr使得这个数组的左半部分没有重复元素且升序,而且不用保证右边是否有序 分区就ok了 u区是 无重复且升序的 u是这个区域的最后位置,初始u=0 i做从左到右的遍历, ...