1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/飞机座位分配概率 [airplane-seat-assignment-probability].html
2022-03-29 12:43:11 +08:00

38 lines
1002 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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><code>n</code> 位乘客即将登机,飞机正好有 <code>n</code> 个座位。第一位乘客的票丢了,他随便选了一个座位坐下。</p>
<p>剩下的乘客将会:</p>
<ul>
<li>
<p>如果他们自己的座位还空着,就坐到自己的座位上,</p>
</li>
<li>当他们自己的座位被占用时,随机选择其他座位</li>
</ul>
<p><code>n</code>&nbsp;位乘客坐在自己的座位上的概率是多少?</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 1
<strong>输出:</strong>1.00000
<strong>解释:</strong>第一个人只会坐在自己的位置上。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong> n = 2
<strong>输出:</strong> 0.50000
<strong>解释:</strong>在第一个人选好座位坐下后,第二个人坐在自己的座位上的概率是 0.5。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10^5</code></li>
</ul>