2037:【例5.4】约瑟夫问题
时间限制: 1000 ms 内存限制: 65536 KB
提交数:62894 通过数: 34779
【题目描述】<span class="MathJax" id="MathJax-Element-1-Frame" tabindex="0" data-mathml="N" role="presentation" style="display: inline; line-height: normal; font-size: 16px; text-indent: 0px; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">N个人围成一圈,从第一个人开始报数,数到<span class="MathJax" id="MathJax-Element-2-Frame" tabindex="0" data-mathml="M" role="presentation" style="display: inline; line-height: normal; font-size: 16px; text-indent: 0px; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">M的人出圈;再由下一个人开始报数,数到<span class="MathJax" id="MathJax-Element-3-Frame" tabindex="0" data-mathml="M" role="presentation" style="display: inline; line-height: normal; font-size: 16px; text-indent: 0px; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">M的人出圈;…输出依次出圈的人的编号。
【输入】输入<span class="MathJax" id="MathJax-Element-4-Frame" tabindex="0" data-mathml="N" role="presentation" style="display: inline; line-height: normal; font-size: 16px; text-indent: 0px; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">N和<span class="MathJax" id="MathJax-Element-5-Frame" tabindex="0" data-mathml="M" role="presentation" style="display: inline; line-height: normal; font-size: 16px; text-indent: 0px; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">M。
【输出】输出一行,依次出圈的人的编号。
【输入样例】8 5【输出样例】5 2 8 7 1 4 6 3【提示】【数据范围】 对于所有数据,<span class="MathJax" id="MathJax-Element-6-Frame" tabindex="0" data-mathml="2≤N,M≤1000" role="presentation" style="display: inline; line-height: normal; font-size: 16px; text-indent: 0px; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">2≤N,M≤1000
[url=]提交[/url]统计信息
本题库与《信息学奥赛一本通(C++版)》(南京大学出版社)配套。
本网站属公益、非盈利性质,不涉及与书相关的商业活动,仅适当接受少量赞助以支持网站的运行维护。
感谢成都石室中学Wuvin、Qizy、Xehoth三位同学。蜀ICP备2024068936号-2 联系我们: 248801752@qq.com 23967609@qq.com |