送诗一首
《竹石》
作者:郑燮 咬定青山不放松,立根原在破岩中。 千磨万击还坚劲,任尔东西南北风。
题目要求P2689题目链接
这题有毛病诶,你看他说“抵达终点的最短时间”,我觉得正常人的解读就应该是没到终点的所有时间吧…… 但实际上根据我WA的情况来看,应该是说“选择顺风行进的时间”……
这题意啊,真的垃圾。
那就没啥可说的了,就算一算位移就行,到了就到了,没到就没到。
到了的话直接坐标相减即可,大可不必计数。
我代码写的有点啰嗦,凑合着看吧……
AC代码(Java语言描述)import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int x1 = scanner.nextInt(), y1 = scanner.nextInt(), x2 = scanner.nextInt(), y2 = scanner.nextInt();
int x = x2 - x1, y = y2 - y1, result = Math.abs(x) + Math.abs(y);
int num = scanner.nextInt();
for (int i = 0; i 0) {
x--;
}
break;
case "W":
if (x 0) {
y--;
}
break;
default:
if (y
关注
打赏
热门博文
- 【Linux】Ubuntu20.04安装和卸载MySQL8
- 【Linux】Ubuntu 20.04 报错 curl: (23) Failure writing output to destination 的解决方法
- 【Java】JUnit 4.13.2 警告 ‘assertEquals(double, double)‘ is deprecated 的解决方法
- 【JavaScript】处理 @parcel/transformer-js: Browser scripts cannot have imports or exports.
- 【Node.js】Windows环境安装配置NVM和Node.js
- 【Python】处理TypeError: Plain typing.NoReturn is not valid as type argument
- 【Python】Matplotlib可视化50例
- 【C语言】C语言修改MySQL数据库
- 【Java】从默认包导入类和对象报错的解决方法
- 【Java】panel.getGraphics()报错空指针异常的解决方法