style:fmt

This commit is contained in:
dichgrem
2025-11-15 13:30:17 +08:00
parent c20e8949a5
commit 41e6b71bd7
33 changed files with 549 additions and 543 deletions

View File

@@ -3,32 +3,32 @@ package com.study.demo;
import java.util.Scanner;
public class test3_5 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] t = new int[n - 1];
int[] s = new int[n];
for (int i = 0; i < n - 1; i++) {
t[i] = scanner.nextInt();
}
for (int i = 0; i < n; i++) {
s[i] = scanner.nextInt();
}
int x = scanner.nextInt();
int y = scanner.nextInt();
int total = 0;
if (x < y) {
for (int i = x - 1; i < y - 1; i++) {
total += s[i] + t[i];
}
total += s[y - 1];
} else {
for (int i = x - 1; i >= y; i--) {
total += s[i] + (i > 0 ? t[i - 1] : 0);
}
total += s[y - 1];
}
System.out.println(total);
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] t = new int[n - 1];
int[] s = new int[n];
for (int i = 0; i < n - 1; i++) {
t[i] = scanner.nextInt();
}
for (int i = 0; i < n; i++) {
s[i] = scanner.nextInt();
}
int x = scanner.nextInt();
int y = scanner.nextInt();
int total = 0;
if (x < y) {
for (int i = x - 1; i < y - 1; i++) {
total += s[i] + t[i];
}
total += s[y - 1];
} else {
for (int i = x - 1; i >= y; i--) {
total += s[i] + (i > 0 ? t[i - 1] : 0);
}
total += s[y - 1];
}
System.out.println(total);
}
}