import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
class ListNode
{
public String val;
public ListNode(String str){
this.val = str;
}
public ListNode next = null;
}
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int k = sc.nextInt();
String[] s1 = s.split(" ");
int length = s1.length;
ListNode node = new ListNode(s1[0]);
for (int i = 1; i
{
ListNode nextNode = new ListNode(s1[i]);
node.next = nextNode;
}
List list1 = new ArrayList<>();
List list2 = new ArrayList<>();
List list3 = new ArrayList<>();
int m = length % k;
int n = length / k;
if(k <= 0)return;
if(k == length){
for (int i = 0; i
{
list3.add(s1[i]);
}
Collections.reverse(list3);
for (int i = 0; i
{
System.out.print(list3.get(i) + " ");
}
return;
}
if(k > length){
for (int i = 0; i
{
list3.add(s1[i]);
}
for (int i = 0; i
{
System.out.print(list3.get(i) + " ");
}
return;
}
for (int i = 0; i
{
for (int j = i * k; j
{
list1.add(s1[j]);
}
Collections.reverse(list1);
list2.addAll(list1);
list1.clear();
}
if(m != 0){
for (int i = n * k; i
{
list2.add(s1[i]);
}
}
for(int i = 0; i
System.out.print(list2.get(i) + " ");
}
}
} 其实可以直接 对list进行操作、操作完之后直接输出就可以了