文章
34
粉丝
89
获赞
2
访问
19.2k
#include <iostream> #include<cstdio> #include<vector> #include<algorithm> #include<cstring> #include<queue> using namespace std; int main(){ int n ; cin >> n; if(n == 1){ cout << 1 <<endl; return 0; } if(n == 2){ cout << 2 <<endl; return 0; } queue<int> myque; for(int i = 3;i <=n;i++){ myque.push(i);//3是队首 } for(int i =1;i < 3;i++){ myque.push(i); } int times = 3;//传花的次数 while(myque.size() != 1){ int cur = myque.front(); myque.pop(); if(times != 3){ myque.push(cur); times++; } else{ times = 1; } } cout << myque.front() << endl; }
登录后发布评论
暂无评论,来抢沙发