import java.util.ArrayList;
import java.util.Scanner;
public class Baoshu {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int len = scanner.nextInt();
ArrayList<Integer> list = new ArrayList<>(len);
for (int i = 0; i < len; i++) {
list.add(i + 1);
}
int delNum = 0; // 删除的次数
int index = 0;
int count = 0;
while (delNum < list.size() - 1) {
if (list.get(index) != 0) {
count++;
if (count == 3) {
// delete
list.set(index, 0);
count = 0;
delNum++;
}
}
index++;
index = index % list.size();
}
// print
for (int each : list) {
if (each != 0) {
System.out.println(each);
}
}
}
}
围圈报数
最新推荐文章于 2022-07-27 09:46:07 发布