zoukankan      html  css  js  c++  java
  • 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的倍数则一定能准确到达;

  • 相关阅读:
    js生成当前时间
    《JavaScript权威指南》读书笔记2
    firefox与ie的兼容(css,html)
    兼容ie ff 等浏览器的jquery,js层移动方法一
    解决文字撑大容器的方法,ie,ff, div,table
    兼容ie ff 等浏览器的jquery,js层移动方法二
    【CSS经典问题】子元素浮动之后如何撑开父元素
    【CSS技巧】列表横向排列的另一种方法
    【CSS经典问题】图片下面有空隙的解决办法
    MYSQL主从复制、主主复制、双主多从配置
  • 原文地址:https://www.cnblogs.com/wsaaaaa/p/4295855.html
Copyright © 2011-2022 走看看