本来是使用的Map<Integer, ArrayList> 来存储的r对应的所有i下标及值 后来发现使用StringBuilder就可以直接进行结果的拼接了,代码如下 public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); while (sc.hasNextInt()){ // 获取I序列中元素个数并存储 int n = sc.nextInt(); int[...