就枚举四种情况,哪种能行就是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. 玩转type类型(牛逼克拉斯 )

    一.前言 一说起type()方法肯定有很多人都知道这不就是查看某个对象类型的嘛,其实不然,他还有更牛逼的应用------创建类 >>> type(1) <class 'int' ...

  2. C#基础之匿名方法实例教程

    本文以实例形式讲解了C#的匿名方法的用法,分享给大家供大家参考之用.具体如下: 匿名方法是C# 2.0的语言新特性.首先看个最简单的例子: class Program { static void Ma ...

  3. PDO:数据访问抽象层

    <?php //PDO:数据访问抽象层 //带有事务功能: //dsn:数据源 $dsn="mysql:host=localhost;dbname=aaas"; //造pdo ...

  4. spring 异步处理request

    转自:http://blog.csdn.net/u012410733/article/details/52124333Spring MVC 3.2开始引入Servlet 3中的基于异步的处理reque ...

  5. C# 调用VS自带程序WebDev.WebServer40.EXE 源代码

    通过Process.Start启动,VS自带程序WebDev.WebServer40.EXE 在内网架设网站时,为安装IIS条件下用VS自带的小程序来测试效果非常不错! using System; u ...

  6. id和NSObject *和instanceType的区别与联系

    id 被成为万能指针,也就是可以指向任何对象. NSObject * 本身就是定义指向NSObject类型的指针. 那么这两者有什么区别吗? 这两者都是既可以作为返回值,又可以作为变量修饰.而其主要区 ...

  7. 【codevs3031】最富有的人(字典树)

    网址:http://codevs.cn/problem/3031/ 这是蒟蒻写的第一道字典树……听说出市选题的神犇要出字符串,于是就赶紧滚去学了学(然而高精度算字符串算法?) 简单来说,字典树就是把一 ...

  8. mongodb,redis简单学习

     2.mongodb安装配置简单学习                   配置好数据库路径就可以mongo命令执行交互操作了:先将服务器开起来:在开个cmd执行交互操作                 ...

  9. 手动用maven安装jar的命令

    手动用maven安装jar的命令: mvn install:install-file -DgroupId=com.oracle.jdbc -DartifactId=ojdbc5 -Dversion=1 ...

  10. 用SQL语句删除除了id不同,其他都相同的学生表信息

    delete from <table_name> wehere id not in (select max(id) from <table_name> group by < ...