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?

Input

You are given three integers ab, and s (?-?109?≤?a,?b?≤?109, 1?≤?s?≤?2·109) in a single line.

Output

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

Examples

input

5 5 11

output

No

input

10 15 25

output

Yes

input

0 5 1

output

No

input

0 0 2

output

Yes

Note

In fourth sample case one possible route is: .

题解:记得加绝对值

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <vector>
 6 #include <cstdlib>
 7 #include <iomanip>
 8 #include <cmath>
 9 #include <ctime>
10 #include <map>
11 #include <set>
12 using namespace std;
13 #define lowbit(x) (x&(-x))
14 #define max(x,y) (x>y?x:y)
15 #define min(x,y) (x<y?x:y)
16 #define MAX 100000000000000000
17 #define MOD 1000000007
18 #define pi acos(-1.0)
19 #define ei exp(1)
20 #define PI 3.141592653589793238462
21 #define INF 0x3f3f3f3f3f
22 #define mem(a) (memset(a,0,sizeof(a)))
23 typedef long long ll;
24 const int N=205;
25 const int mod=1e9+7;
26 int main()
27 {
28     ll a,b,s;
29     while(cin>>a>>b>>s){
30         a=llabs(a),b=llabs(b);
31         int flag=1;
32         if(a+b>s) flag=0;
33         else {
34             if(a+b==0&&s%2==0) flag=1;
35             else if(a+b==0&&s%2==1) flag=0;
36             else {
37                 ll t=s-(a+b);
38                 if(t%2==0) flag=1;
39                 else flag=0;
40             }
41         }
42         if(flag) cout<<"Yes"<<endl;
43         else cout<<"No"<<endl;
44     }
45     return 0;
46 }
时间: 2024-09-29 23:40:23

Codeforce 515A - Drazil and Date的相关文章

codeforces 515A.Drazil and Date 解题报告

题目链接:http://codeforces.com/problemset/problem/515/A 题目意思:问能否从 (0, 0) 出发,恰好走 s 步,到达该位置(a, b). 首先容易知道,最少的步数为 |a| + |b|,最长就是——当然是无限啦(乱兜圈子就行).然后就有一点点带着个人感觉来做了= =,第六感确实不错的,呵呵,证明就有待考究了. 如果 |a| + |b| 跟 s 的奇偶性相同就有解,否则无解.当然前提是满足 s 至少要比最少的步数大! 1 #include <iost

A. Drazil and Date

这是codeforces#292 div2 的一道题,因为本人比较水,目前只能做div2了.问题简化版就是: 从 (0,0) 走到 (a, b) ,s 步能不能走完.每次能向上下左右走,且只能走一步. 一开始,要从(0, 0) 走到 (a, b) ,至少走 |a| + |b| 步,对不对?你自己试一下.所以,当你从(0, 0) 走到 (2, 3) ,要是5步,则刚好能够走到(2, 3), 要是6步呢,无论你怎么走,在到达(2, 3)后,总会多出一步,这样的话,到目的地(2, 3) 后,又多出一步

Codeforces Round #292 (Div. 2 Div. 1)

比赛链接:http://codeforces.com/contest/515  http://codeforces.com/contest/516 A. Drazil and Date time limit per test 1 second memory limit per test 256 megabytes Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. D

codeforce 809ADo you want a date?

Leha decided to move to a quiet town Vi?kopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to expand his network of hacked computers. During the week Leha managed to get access to n computers throughout the town.

Codeforce 810C Do you want a date?

题意: 给定n个不重复的数, 求出这些数的所有子集, 然后设一个数Ni 为 第i个子集中,最大的数 - 最小的数. 然后将i个 Ni求和, 结果mod 1e9 + 7. 分析: 首先将n个数排列,生成一个单调的数列. 举个例子, 如 1 3 5 7 9. 可以看出 1 作为一个子集中最小的数会有 2^4 - 1 = 15种(1 和 3 5 7 9组合, 3 5 7 9任意的非空子集有2^4 - 1种) , 作为最大的数有2^0 - 1 = 0(因为没有数比1小). 同理 9 作为一个子集中最小的

CodeForce 113B DP

Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in some order. Now he should find t

CodeForce 117C Cycle DFS

A tournament is a directed graph without self-loops in which every pair of vertexes is connected by exactly one directed edge. That is, for any two vertexes u and v (u ≠ v) exists either an edge going from u to v, or an edge from v to u. You are give

Two progressions CodeForce 125D 思维题

An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progressi

js中获取时间new date()的用法

js中获取时间new date()的用法 获取时间:   var myDate = new Date();//获取系统当前时间 获取特定格式的时间: 1 myDate.getYear(); //获取当前年份(2位) 2 myDate.getFullYear(); //获取完整的年份(4位,1970-????) 3 myDate.getMonth(); //获取当前月份(0-11,0代表1月) 4 myDate.getDate(); //获取当前日(1-31) 5 myDate.getDay();