笔试的时候碰到的,cvte的笔试,竟然不支持本地IDE编写
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
List<Integer> list=new ArrayList<>();
for(int i=1;i<=n;i++) {
list.add(i);
}
int start=-1;
while(!list.isEmpty()) {
int step=0;
int end=0;
while(step!=m) {
step++;
end=start+step;
end=end%(list.size());
}
System.out.print(list.get(end)+" ");
list.remove(end);
if(list.size()==0)
return;
start=(end-1)%(list.size());
}
sc.close();
}
}