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的倍数则一定能准确到达;

  • 相关阅读:
    设置一个alias直接推到github
    JSON
    分部式类定义
    sql server 2008 不允许保存更改,您所做的更改要求删除并重新创建以下表 的解决办法
    ibatis 连接数据库时的错误
    ibatis 连接数据库
    [ASP.NET] C#字符串处理
    20130401学习笔记
    最大公约数和最小公倍数
    从客户端中检测到有潜在危险的 Request.Form 值 解决方案
  • 原文地址:https://www.cnblogs.com/wsaaaaa/p/4295855.html
Copyright © 2011-2022 走看看