【codeforces 515A】Drazil and Date
2017-10-04 18:44
417 查看
【题目链接】: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; }
相关文章推荐
- CodeForces - 515A Drazil and Date
- Drazil and Date(515A)
- 【codeforces】515-D Drazil and Tiles
- 【codeforces 515B】Drazil and His Happy Friends
- 【codeforces 516B】Drazil and Tiles
- Codeforces Round #292 (Div. 2) -- A. Drazil and Date
- Codeforces Round #292 (Div. 2)——A——Drazil and Date
- Codeforces Round #292 (Div. 2) A. Drazil and Date
- codeforces 515B B. Drazil and His Happy Friends(模拟)
- [数论] Codeforces 819D R #421 D.Mister B and Astronomers & 516E R #292 E. Drazil and His Happy Friends
- Drazil and Tiles(CodeForces 515D)
- A. Drazil and Date
- A. Drazil and Date
- A. Drazil and Date
- 【CodeForces 513C】Drazil and Factorial
- Codeforces-515C-Drazil and Factorial
- Codeforces 515D - Drazil and Tiles (拓扑排序)
- Drazil and Date
- 【CodeForces】C. Drazil and Factorial
- Codeforces Round #292 (Div. 2) -- A. Drazil and Date