Run ID:111520
提交时间:2025-03-02 15:18:42
#include<bits/stdc++.h> using namespace std; int n, m ;// n是人数,m是谁报道m谁死 int hz[1000]; // hz[i]=1就表示是第i个人挂了,hz[i]=0表示第i个人活着 int main(){ cin >> n >> m; int ren = 0; int bs = 0; int live = n;// 一开始活着的人是n个 while(live != 1){ // 只要活着的人不是一个,游戏就得继续 ren++; if(ren == n+1){ // 如果是第n+1个人报的,其实就相当于是第1个人报的 ren = 1; } if(hz[ren] == 1){ // 这个人已经挂了,跳过 continue; } bs++; // 没有跳过,说明该他报数 if(bs == m){ hz[ren] = 1; // 这个人噶了 cout << ren << " "; bs = 0; live--; // 活着的人少一 } } return 0; }