1 Star 0 Fork 0

向宇 / 初学之旅:2022大一秋

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
清华算竞例1(洛谷P1996)(STL list实现) 540 Bytes
一键复制 编辑 原始数据 按行查看 历史
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m; cin>>n>>m;
list<int>node;
for(int i=1;i<=n;i++) node.push_back(i);
list<int>::iterator it=node.begin();
while(node.size()>1){
for(int i=1;i<m;i++)
{
it++;
if(it==node.end()) it=node.begin();
}
cout<<*it<<" ";
list<int>::iterator next=++it;
if(next==node.end()) next=node.begin();
node.erase(--it);
it=next;
}
cout<<*it;
return 0;
}
C
1
https://gitee.com/X_yugg1/learning-journey.git
git@gitee.com:X_yugg1/learning-journey.git
X_yugg1
learning-journey
初学之旅:2022大一秋
master

搜索帮助