题目链接:http://codeforces.com/problemset/problem/515/A

题目意思:问能否从 (0, 0) 出发,恰好走 s 步,到达该位置(a, b)。

  首先容易知道,最少的步数为 |a| + |b|,最长就是——当然是无限啦(乱兜圈子就行)。然后就有一点点带着个人感觉来做了= =,第六感确实不错的,呵呵,证明就有待考究了。

  如果 |a| + |b| 跟 s 的奇偶性相同就有解,否则无解。当然前提是满足 s 至少要比最少的步数大!

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std; int main() {
int a, b, s;
while (scanf("%d%d%d", &a, &b, &s) != EOF) {
int mindist = abs(a) + abs(b);
if (mindist > s)
printf("No\n");
else {
if (mindist & && s & )
printf("Yes\n");
else if (mindist % == && s % == )
printf("Yes\n");
else
printf("No\n");
}
}
return ;
}

最新文章

  1. 机器学习笔记——支持向量机 (SVM)
  2. MySQL修改root密码的各种方法整理
  3. 【LEETCODE OJ】Single Number
  4. WCF z
  5. asp.net mvc 错误路由默认配置
  6. HDU4578 Transformation 线段树
  7. 【Android自动化打包】03. APK的数字签名
  8. web项目学习之spring-security
  9. HTML5 canvas 绘制精美的图形
  10. 得到一个临时的文件名称(使用GetTempFileName API函数)
  11. Linux经常使用的命令-权利管理命令-权利管理命令chmod
  12. c# 自定义多选下拉列表2
  13. fputcsv 导出CSV、Excel DownLoad
  14. dojo报错总结
  15. BZOJ_3011_[Usaco2012 Dec]Running Away From the Barn _可并堆
  16. Centos 部署.net Core
  17. PHP base64数据与图片的互相转换
  18. android 去掉activity的切换动画
  19. Windows环境下文件的彻底删除与恢复,推荐几个工具(整理)
  20. MapReduce: number of mappers/reducers

热门文章

  1. Emacs配置文件
  2. JS抽奖功能代码
  3. Some Delphi tips
  4. nyoj 289 苹果 动态规划 (java)
  5. No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
  6. POJ 2155 Matrix
  7. Hadoop之Storm命令
  8. int (*p)[4] 与 int* p[4]
  9. Entity Framework Code First数据库自动更新2
  10. Spring 事务知识