就枚举四种情况,哪种能行就是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(暴力枚举)的更多相关文章

  1. Codeforces Round #253 (Div. 2)B(暴力枚举)

    就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...

  2. Codeforces Round #258 (Div. 2)[ABCD]

    Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...

  3. Codeforces Round #258 (Div. 2) 小结

    A. Game With Sticks (451A) 水题一道,事实上无论你选取哪一个交叉点,结果都是行数列数都减一,那如今就是谁先减到行.列有一个为0,那么谁就赢了.因为Akshat先选,因此假设行 ...

  4. 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 ...

  5. 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三队赢的场次的关系 ...

  6. 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 ...

  7. Codeforces Round #258 (Div. 2) B. Sort the Array

    题目链接:http://codeforces.com/contest/451/problem/B 思路:首先找下降段的个数,假设下降段是大于等于2的,那么就直接输出no,假设下降段的个数为1,那么就把 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. vim之可视化

    参考文档:http://blog.csdn.net/ii1245712564/article/details/46960387 先梳理关键知识,方便查阅 v(小v):进入可视化 V(大V):进入可视行 ...

  2. nginx负载均衡详情

    负载均衡是我们大流量网站要做的一个东西,下面我来给大家介绍在Nginx服务器上进行负载均衡配置方法,希望对有需要的同学有所帮助哦. 负载均衡 先来简单了解一下什么是负载均衡,单从字面上的意思来理解就可 ...

  3. Android开发之旅-获取地理位置的经度和纬度

    在Android应用程序中,可以使用LocationManager来获取移动设备所在的地理位置信息.看如下实例:新建android应用程序TestLocation. 1.activity_main.x ...

  4. 【TopCoder】SRM160 DIV1总结

    做了两道题之后才发现做的是DIV1,不是DIV2,DIV1的第二道题是DIV1的第三道题,果断决定第3题就不看了=.= 250分题:给定一个时间起点8:00 AM DAY 1,再给出一组时间终点,格式 ...

  5. RTC是DS1339,驱动采用的是rtc-ds1307.c

    我的外部RTC是DS1339,驱动采用的是rtc-ds1307.c在内核里选上了 <*> I2C support 以及 [*]   Set system time from RTC on  ...

  6. 二、linux题型

    1.[root@pyrene ~]# 这里root是当前登录用户  @分割     pyrene是主机名    -:表示当前登录环境   #:表示管理员 2.在/data下面创建一个文件oldboy. ...

  7. 添加nginx服务到service的过程

    Linux命令service - 系统服务管理(转) 用途说明 service命令用于对系统服务进行管理,比如启动(start).停止(stop).重启(restart).查看状态(status)等. ...

  8. Bluetooth Profile for iPhone from the functional perspectives

    Classic Bluetooth Profile for iPhone from the functional perspectives Function Description BT Profil ...

  9. 【转】php 操作数组(合并,拆分,追加,查找,删除等)

    1. 合并数组 array_merge()函数将数组合并到一起,返回一个联合的数组.所得到的数组以第一个输入数组参数开始,按后面数组参数出现的顺序依次迫加.其形式为: array array_merg ...

  10. ViewPagerAdapter

    ) { ; } } @Override public boolean isViewFromObject(View arg0, Object arg1) { return arg0 == arg1; } ...