题目要求
P2077题目链接
思路无非是先开过平路,在十字路口红灯停、绿灯行,对总时间做个计数,每次通过取模知道当前时间是红绿灯。 数要先读进来,只能先存一下数组了。
读的数多,用BufferedReader就行,Scanner抗不下来。
AC代码(Java语言描述)import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] arr = reader.readLine().split(" ");
int num = Integer.parseInt(arr[0]);
int[] distance_array = new int[num];
int[] red_time_array = new int[num];
int[] green_time_array = new int[num];
distance_array[0] = Integer.parseInt(arr[1]);
arr = reader.readLine().split(" ");
for (int i = 1; i
关注
打赏
热门博文
- 【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()报错空指针异常的解决方法