AcWing 郑轻 3108. 公交车上的座位 (模拟
原题链接
简单
作者:
JustDoIt11
,
2023-12-03 18:09:00
,
所有人可见
,
阅读 47
import java.util.Arrays;
import java.util.Scanner;
public class J {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
int[][] w = new int[n + 1][5];
for (int i = 1; i <= m; i ++ ) {
// if (i == 12) System.out.println("debug");
if (i <= 2 * n) {
if (i % 2 == 1) w[(i + 1) / 2][1] = i;
else w[(i + 1) / 2][4] = i;
} else {
if (i % 2 == 1) w[(i - 2 * n + 1) / 2][2] = i;
else w[(i - 2 * n + 1) / 2][3] = i;
}
}
// for (int i = 1; i <= n; i ++ ) System.out.println(Arrays.toString(w[i]));
for (int i = 1; i <= n; i ++ ) {
if (w[i][2] != 0) System.out.print(w[i][2] + " ");
if (w[i][1] != 0) System.out.print(w[i][1] + " ");
if (w[i][3] != 0) System.out.print(w[i][3] + " ");
if (w[i][4] != 0) System.out.print(w[i][4] + " ");
}
}
}