Codeforce 515A - Drazil and Date
Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home is located in point (a, b). In each step, he can move in a unit distance in horizontal or vertical direction. In other words, from position (x, y) he can go to positions (x + 1, y), (x - 1, y), (x, y + 1) or (x, y - 1).
Unfortunately, Drazil doesn't have sense of direction. So he randomly chooses the direction he will go to in each step. He may accidentally return back to his house during his travel. Drazil may even not notice that he has arrived to (a, b) and continue travelling.
Luckily, Drazil arrived to the position (a, b) successfully. Drazil said to Varda: "It took me exactly s steps to travel from my house to yours". But Varda is confused about his words, she is not sure that it is possible to get from (0, 0) to (a, b) in exactly s steps. Can you find out if it is possible for Varda?
You are given three integers a, b, and s ( - 109 ≤ a, b ≤ 109, 1 ≤ s ≤ 2·109) in a single line.
If you think Drazil made a mistake and it is impossible to take exactly s steps and get from his home to Varda's home, print "No" (without quotes).
Otherwise, print "Yes".
5 5 11
No
10 15 25
Yes
0 5 1
No
0 0 2
Yes
In fourth sample case one possible route is: .
题解:记得加绝对值
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int N=;
const int mod=1e9+;
int main()
{
ll a,b,s;
while(cin>>a>>b>>s){
a=llabs(a),b=llabs(b);
int flag=;
if(a+b>s) flag=;
else {
if(a+b==&&s%==) flag=;
else if(a+b==&&s%==) flag=;
else {
ll t=s-(a+b);
if(t%==) flag=;
else flag=;
}
}
if(flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return ;
}
Codeforce 515A - Drazil and Date的更多相关文章
- codeforces 515A.Drazil and Date 解题报告
题目链接:http://codeforces.com/problemset/problem/515/A 题目意思:问能否从 (0, 0) 出发,恰好走 s 步,到达该位置(a, b). 首先容易知道, ...
- CF Drazil and Date (奇偶剪枝)
Drazil and Date time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 【codeforces 515A】Drazil and Date
[题目链接]:http://codeforces.com/contest/515/problem/A [题意] 每次只能走到相邻的四个格子中的一个; 告诉你最后走到了(a,b)走了多少步->s ...
- A. Drazil and Date
这是codeforces#292 div2 的一道题,因为本人比较水,目前只能做div2了.问题简化版就是: 从 (0,0) 走到 (a, b) ,s 步能不能走完.每次能向上下左右走,且只能走一步. ...
- CodeForces 515A
A. Drazil and Date time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #292 (Div. 2)
A. Drazil and Date 无算法,判断(s - (a + b)) % 2是否为零,若零,表示在s步内还能走向其他的地方并且回来 否则,都是No #include <cstdio> ...
- Codeforce 810C Do you want a date?
题意: 给定n个不重复的数, 求出这些数的所有子集, 然后设一个数Ni 为 第i个子集中,最大的数 - 最小的数. 然后将i个 Ni求和, 结果mod 1e9 + 7. 分析: 首先将n个数排列,生成 ...
- Two progressions CodeForce 125D 思维题
An arithmetic progression is such a non-empty sequence of numbers where the difference between any t ...
- CodeForce 577B Modulo Sum
You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choo ...
随机推荐
- C# 数据类型详解以及变量、对象与内存
学习刘铁猛老师<C#语言入门详解>视频,针对其中重点知识点进行总结. 1.什么是类型? 类型又称为数据类型(Data Type),数据类型在数据结构中的定义是一个值的集合以及定义在这个值集 ...
- STT-MRAM万能存储器芯片
传统存储器的技术局限以及不断缩小的制造尺寸所带来的巨大挑战促使科研人员开始寻找新一代存储器件,它应具有接近静态存储器的纳秒级读写速度,具有动态存储器甚至闪存级别的集成密度和类似Flash的非易失性存储 ...
- C#中StreamWriter类使用总结
C#中StreamWriter类使用总结 1.使用的命名空间是:System.IO; 2.用来将字符串写入文件. 常用属性: AutoFlush:获取或设置一个值,该值指示是否 System.IO ...
- Django csrf校验
引入: 通常,钓鱼网站本质是本质搭建一个跟正常网站一模一样的页面,用户在该页面上完成转账功能 转账的请求确实是朝着正常网站的服务端提交,唯一不同的在于收款账户人不同. 如果想模拟一个钓鱼网站,就可是给 ...
- clr via c# 定制特性
1,特性的应用范围:特性可应用于程序集,模块,类型,字段,方法,方法参数,方法返回值,属性,参数,泛型参数 2,利用前缀告诉编译器表明意图---下面的倾斜是必须的表明了我们的目标元素: [assemb ...
- Linux基础:df命令总结
本文只总结一些常用的用法,更详细的说明见man df和 df --help. df命令 df命令用于显示目前在Linux系统上的文件系统的磁盘使用情况统计. df命令主要是从各文件系统的Super b ...
- string_random
1.随机数 import random 0-1间的随机浮点数,random.random() 指定区间随机浮点数,random.uniform(a,b) 指定区间随机整数(闭区间),random.ra ...
- webserver代理生成本地类的两种方式
方式1,把webservers地址请求出来的xml拷贝出来放到文本里面后缀改成wsdl文件在VS里面使用下列命令 C:\Program Files (x86)\Microsoft SDKs\Windo ...
- Python集合详解
集合介绍: 集合(set)是一个无序的不重复元素序列.可以使用大括号 { } 或者 set() 函数创建集合,注意:创建一个空集合必须用 set() 而不是 { },因为 { } 是用来创建一个空字典 ...
- python 学习笔记之手把手讲解如何使用原生的 urllib 发送网络请求
urllib.urlopen(url[,data[,proxies]]) : https://docs.python.org/2/library/urllib.html python 中默认自带的网络 ...