【codeforces 515A】Drazil and Date

【题目链接】:http://codeforces.com/contest/515/problem/A

【题意】

每次只能走到相邻的四个格子中的一个;
告诉你最后走到了(a,b)走了多少步->s
(你一开始在位置(0,0)
问你可不可能;

【题解】

先算出从0,0走到(a,b)的步数(最短)->temp;
之后,如果s-temp为偶数就可行,否则不可行;
(s< temp肯定不行);
为偶数的话,去了可以再回来.
没看到a,b能为负数。。

【Number Of WA

1

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
#define ref(x) scanf("%lf",&x)

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 110;

LL a, b, s;

int main()
{
    //freopen("F:\\rush.txt", "r", stdin);
    cin >> a >> b >> s;
    a = abs(a), b = abs(b);
    LL temp = a + b;
    if (s < temp) return puts("No"), 0;
    temp = s - temp;
    if (temp % 2 == 0) return puts("Yes"), 0;
    puts("No");
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}
posted @ 2017-10-04 18:44  AWCXV  阅读(119)  评论(0编辑  收藏  举报