A .Drazil and Date

题目大意:问是否有一条路径,从(0,0)到(x,y)正好走s步的路线存在,每步可以上下左右移动一格

思路:显然先计算出(0,0)到(x,y)的最短距离后,看剩下的步数是否是偶数就可以了,注意x,y为负数的情况

 1 #include<cstdio>
 2 #include<algorithm>
 3 using namespace std;
 4 int mabs(int x)
 5 {
 6     if(x>0)return x;else return -x;
 7 }
 8 int main()
 9 {
10     int n,m,step;
11     scanf("%d%d%d",&n,&m,&step);
12     int u=mabs(n)+mabs(m);
13     if(u>step)printf("No\n");
14     else if((step-u)&1)printf("No\n");
15     else printf("Yes\n");
16     return 0;
17 }
View Code

相关文章: