codeforces 515A.Drazil and Date 解题报告
2024-10-10 17:04:15
题目链接: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 ;
}
最新文章
- 机器学习笔记——支持向量机 (SVM)
- MySQL修改root密码的各种方法整理
- 【LEETCODE OJ】Single Number
- WCF z
- asp.net mvc 错误路由默认配置
- HDU4578 Transformation 线段树
- 【Android自动化打包】03. APK的数字签名
- web项目学习之spring-security
- HTML5 canvas 绘制精美的图形
- 得到一个临时的文件名称(使用GetTempFileName API函数)
- Linux经常使用的命令-权利管理命令-权利管理命令chmod
- c# 自定义多选下拉列表2
- fputcsv 导出CSV、Excel DownLoad
- dojo报错总结
- BZOJ_3011_[Usaco2012 Dec]Running Away From the Barn _可并堆
- Centos 部署.net Core
- PHP base64数据与图片的互相转换
- android 去掉activity的切换动画
- Windows环境下文件的彻底删除与恢复,推荐几个工具(整理)
- MapReduce: number of mappers/reducers
热门文章
- Emacs配置文件
- JS抽奖功能代码
- Some Delphi tips
- nyoj 289 苹果 动态规划 (java)
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- POJ 2155 Matrix
- Hadoop之Storm命令
- int (*p)[4] 与 int* p[4]
- Entity Framework Code First数据库自动更新2
- Spring 事务知识