Time limit1000 ms Memory limit262144 kB
total:
Time
46ms
Memory
12kB
原题:
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 a, b, 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”.
翻译
有一天,Drazil想与Varda约会。Drazil和Varda住在笛卡尔飞机上。Drazil的家位于点(0,0),Varda的家位于点(a,b)。在每个步骤中,他可以在水平或垂直方向上以单位距离移动。换句话说,从位置(x,y),他可以到达位置(x + 1,y),(x-1,y),(x,y + 1)或(x,y-1)。不幸的是,德拉齐没有方向感。所以他随机选择了每一步的方向。他在旅行期间可能会不小心回到自己的房子里。德拉齐甚至没有注意到他已经到达(a,b)并继续旅行。幸运的是,Drazil成功抵达了位置(a,b)。德拉齐对瓦尔达说:“从我的房子到你的房子,我花了很多步。”但是Varda对他的话语感到困惑,她不确定是否有可能以恰好的步骤从(0,0)到(a,b)。你能知道Varda是否有可能吗?
输入
在一行中给出三个整数a,b和s( - 109≤a,b≤109,1≤s≤2·109)。
产量如果你认为Drazil犯了一个错误并且不可能采取正确的步骤并从他的家到Varda的家,打印“No”(没有引号)。否则,请打印“是”。
否则,请打印“是”。
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
题目思路:问题里面很清楚,画个坐标轴基本知道s和ab之间是什么关系了,
现在来看下细节:
1.最基本的s=a+b,那肯定yes;s<a+b就no,
2.但是如果s>a+b呢;肯定是走出1步,返回一步;或者走一个正方形要4步,在坐标轴上其实不难发现(s-(a+b))%=0时均能刚好回到那个坐标点(a,b).
3.首先坐标点是有正负的;但是我们走的步数肯定为正,则s>0,当然acm的题,我们不用限制这个,但是我们计算走几步路时,那就要把a,b的输入数据转化为正数了
题目大概就这么多细节,在输入给出的条件里,可以看出肯定要用long int
AC通过的C++语言程序如下:
#include <iostream>
#include<cstdlib> //调用长整形绝对值函数,老手忽视
using namespace std;
void printmessage( long int a, long int b, long int c); //长数据,无返回
int main()
{
int i, j, k;
cin >> i >> j>>k;
printmessage(i, j, k); //这里有一个细节,直接调用函数,不能用cout,不然会返回输入的最后一个数据,老手忽视
system("pause");
return 0;
}
void printmessage( long int a, long int b, long int c)
{
long int x, y, z;
x = labs(a);
y = labs(b);
if ((c -x- y) < 0)
cout << "no" << endl;
else
{
z = (c - x - y) % 2;
if (z == 0)
cout << "yes" << endl;
else cout << "no" << endl;
}
}