1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/圆圈中最后剩下的数字 [yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof].html
2022-03-29 12:43:11 +08:00

29 lines
796 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>0,1,···,n-1这n个数字排成一个圆圈从数字0开始每次从这个圆圈里删除第m个数字删除后从下一个数字开始计数。求出这个圆圈里剩下的最后一个数字。</p>
<p>例如0、1、2、3、4这5个数字组成一个圆圈从数字0开始每次删除第3个数字则删除的前4个数字依次是2、0、4、1因此最后剩下的数字是3。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong> n = 5, m = 3
<strong>输出: </strong>3
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong> n = 10, m = 17
<strong>输出: </strong>2
</pre>
<p> </p>
<p><strong>限制:</strong></p>
<ul>
<li><code>1 <= n <= 10^5</code></li>
<li><code>1 <= m <= 10^6</code></li>
</ul>