QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#11513. 行列式反击

统计

Dinara 有一个整数 $x$ 和两个长度为 $n$ 的数组 $a_1, \dots, a_n$ 和 $b_1, \dots, b_n$。她构造了一个 $n \times n$ 的矩阵 $M$,其中:

$$M_{i,j} = \begin{cases} x + a_i b_j & \text{当 } i = j \\ a_i b_j & \text{其他情况} \end{cases}$$

求矩阵 $M$ 的行列式对 $(10^9 + 7)$ 取模的结果。

输入格式

输入包含多组测试数据,以文件结束符(EOF)结束。 每组测试数据的第一行包含两个整数 $n$ 和 $x$。第二行包含 $n$ 个整数 $a_1, \dots, a_n$。第三行包含 $n$ 个整数 $b_1, \dots, b_n$。

  • $1 \le n \le 10^5$
  • $0 \le x, a_i, b_i \le 10^9$
  • 所有测试数据的 $n$ 之和不超过 $10^6$。

输出格式

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

样例

样例输入 1

2 1
0 0
0 0
2 1
1000000000 1000000000
1000000000 1000000000
3 2
2 3 3
2 3 3

样例输出 1

1
99
96

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.