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)/有效的快递序列数目 [count-all-valid-pickup-and-delivery-options].html

41 lines
1.1 KiB
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>给你&nbsp;<code>n</code>&nbsp;笔订单,每笔订单都需要快递服务。</p>
<p>计算所有有效的 取货 / 交付 可能的顺序,使 delivery(i) 总是在 pickup(i) 之后。</p>
<p>由于答案可能很大,请返回答案对 10^9 + 7 取余的结果。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 1
<strong>输出:</strong>1
<strong>解释:</strong>只有一种序列 (P1, D1),物品 1 的配送服务D1在物品 1 的收件服务P1后。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 2
<strong>输出:</strong>6
<strong>解释:</strong>所有可能的序列包括:
(P1,P2,D1,D2)(P1,P2,D2,D1)(P1,D1,P2,D2)(P2,P1,D1,D2)(P2,P1,D2,D1) 和 (P2,D2,P1,D1)。
(P1,D2,P2,D1) 是一个无效的序列,因为物品 2 的收件服务P2不应在物品 2 的配送服务D2之后。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>n = 3
<strong>输出:</strong>90
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 500</code></li>
</ul>