QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#3755. 4个按钮

统计

Bobo 生活在一个无限大的棋盘上。最初他位于 $(0, 0)$。棋盘上有 $4$ 个按钮。

  • 按下第一个按钮,Bobo 向右移动至多 $a$ 个格子。
  • 按下第二个按钮,Bobo 向上移动至多 $b$ 个格子。
  • 按下第三个按钮,Bobo 向左移动至多 $c$ 个格子。
  • 按下第四个按钮,Bobo 向下移动至多 $d$ 个格子。

如果 Bobo 按下按钮的次数不超过 $n$ 次,求他能到达的格子数量,结果对 $(10^9+7)$ 取模。

输入格式

输入包含多组测试数据,以文件结束符(EOF)结束。

每个测试用例包含五个整数 $n, a, b, c, d$。

  • $1 \leq n, a, b, c, d \leq 10^9$
  • 测试用例数量不超过 $10^5$。

输出格式

对于每个测试用例,输出一个整数,表示结果。

样例

样例输入 1

1 1 2 3 4
2 1 1 1 1
1000000000 1000000000 1000000000 1000000000 1000000000

样例输出 1

11
13
5685

说明

对于第一个测试用例,Bobo 可以到达以下 $11$ 个格子: $(-3, 0)$, $(-2, 0)$, $(-1, 0)$, $(0, -4)$, $(0, -3)$, $(0, -2)$, $(0, -1)$, $(0, 0)$, $(0, 1)$, $(0, 2)$, $(1, 0)$。

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.