• A. Drazil and Date


    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

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

    Sample test(s)
    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<cstdio>
     2 #include<cstring>
     3 #include<iostream>
     4 #include<cmath>
     5 using namespace std;
     6 
     7 int main()
     8 {
     9     int x,y,s;
    10     cin>>x>>y>>s;
    11     if(abs(x)+abs(y)<=s&&(int)(s-abs(x)-abs(y))%2==0) cout<<"Yes"<<endl;
    12     else cout<<"No"<<endl;
    13 }

    坐标点

    分析:上下左右每次只行走一个单位 那么到达指定坐标(x,y)的最小距离一定为|x|+|y| 此时如果步数s小于则一定到不了,如果大于并且多余的步数是2的倍数则一定能准确到达;

  • 相关阅读:
    LeetCode105. 从前序与中序遍历序列构造二叉树
    Flask 基础
    24个常用 Python 实现
    大佬的编码建议,让你的代码更pythonic
    rest-framework框架之序列化
    路飞学城项目之加入结算中心接口
    java异常与spring事务关系的知识点查漏补缺
    iserver-数据库型数据源导入后原dataset名称和数据库表名不一致的问题
    解决数据读取的负载均衡的问题
    Nginx反向代理、CORS、JSONP等跨域请求解决方法总结
  • 原文地址:https://www.cnblogs.com/wsaaaaa/p/4295855.html
Copyright © 2020-2023  润新知