#牛客创作赏金赛#import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); // 构造拉丁方阵 int[][] matrix = new int[n][n]; for (int i = 0; i for (int j = 0; j matrix[i][j] = (i + j) % n + 1; } } // 计算每一行和每一列的异或和 int minThreshold = 0; for (int i = 0; i int rowXor = 0, colXor = 0; for (int j = 0; j rowXor ^= matrix[i][j]; colXor ^= matrix[j][i]; } minThreshold = Math.max(minThreshold, Math.max(rowXor, colXor)); } // 输出结果 System.out.println(minThreshold); for (int i = 0; i for (int j = 0; j System.out.print(matrix[i][j] + " "); } System.out.println(); } }}#ai智能作图#