Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
111520 | 彭林江 | 杀人游戏 | C++ | Accepted | 1 MS | 280 KB | 766 | 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; }