QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#11225. 螺旋矩阵

الإحصائيات

Lee 拿到了 Google 开发者大会的门票。当他来到展厅时,发现展位位于一个 $n \times m$ 的矩阵中。

不幸的是,Lee 在 GDD 前一周打篮球时严重扭伤了左脚踝。因此,他无法像往常一样自由走动。如果他尝试向左转,脚踝会感到疼痛。此外,Lee 也不想通过多次右转来完成一个大转弯,因为那样看起来很傻。

Lee 想要恰好访问每个展位一次。考虑到他的脚踝状况,他制定了一些访问展位的规则。他可以从展厅中的任意展位开始,并选择一个初始方向。此后的每一步移动都必须遵循以下可能的操作之一:

  1. 直行访问下一个展位。
  2. 向右转一次,然后直行访问下一个展位。

你是 Lee 的朋友,并且有帮助他的好习惯。你能算出恰好访问每个展位一次的不同路径数量吗?如果两种方式的访问顺序不同,则认为它们是不同的。

输入格式

第一行包含测试用例的数量 $T$ ($1 \le T \le 100$)。接下来是 $T$ 个测试用例。 每个测试用例仅包含一行,包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 100$),分别表示矩阵的行数和列数。

输出格式

对于每个测试用例,输出一行 “Case #x: y”,其中 $x$ 是测试用例编号(从 1 开始),$y$ 是不同路径的数量对 $(10^9 + 7)$ 取模的结果。

样例

输入格式 1

1
2 2

输出格式 1

Case #1: 4

说明

以下是 $n = 2, m = 2$ 时的 4 种不同路径。

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.