QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#17972. 海岸线

統計

在一个圆形海岸线上有 $N$ 个城市。这些城市按顺时针方向从 $1$ 到 $N$ 编号。对于所有城市对,都存在一条连接这两个城市的双向道路。

在所有这些道路中,我们称连接城市 $a$ 和 $b$ 的道路为特殊道路。特殊道路连接的两个城市都不是城市 $1$,且已知它是风景最美的道路。

Jeongseo 计划按照以下方法仅通过道路在这些城市之间旅行:

  • 他的旅行从城市 $1$ 开始。在旅行开始的瞬间,城市 $1$ 被视为已被访问。
  • 在旅行过程中,他不应访问任何已经访问过的城市(包括城市 $1$),且每个城市必须恰好被访问一次。
  • 旅行路线中使用的任何道路都不能相互交叉。
  • 在旅行中必须恰好使用一次特殊道路。以哪个方向通过该特殊道路均可。

求满足上述所有条件的旅行路径数量。

输入格式

第一行输入包含一个正整数 $N$,表示城市的数量。($3 \leq N \leq 1\,000\,000$)

第二行输入包含两个空格分隔的整数 $a$ 和 $b$,表示由特殊道路连接的两个城市。($2\leq a, b \leq N$;$a\neq b$)

输出格式

输出满足题目描述中条件的路径总数模 $1\,000\,000\,007$ 的结果。

样例

输入样例 1

4
2 4

输出样例 1

2

输入样例 2

6
5 4

输出样例 2

11

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.