Universal Cup Judging System

Universal Cup

時間限制: 3.0 s 記憶體限制: 1024 MB 總分: 100 难度: [顯示] 可 Hack ✓
统计

Little Cyan Fish 热爱模运算,并且是掌握模运算技巧的大师。

为了测试你是否真正理解了模运算的精髓,Little Cyan Fish 给了你一个包含 $n$ 个正整数的序列 $a_1, a_2, \dots, a_n$。

然后,你被允许执行以下操作,最多 $2n + 10$ 次:

  1. 选择一个整数 $1 \le x \le 10^9$。
  2. 选择两个下标 $i$ 和 $j$,使得 $1 \le i, j \le n$ 且 $i \neq j$。
  3. 更新序列:
    • $a_i \leftarrow a_i \pmod x$
    • $a_j \leftarrow a_j \cdot x$

Little Cyan Fish 希望你对序列 $a$ 进行一些操作,使得最终序列 $a$ 变为另一个序列 $b_1, b_2, \dots, b_n$。你能判断这是否可行吗?

输入格式

输入包含多组测试数据。第一行包含一个整数 $T$ ($T \ge 1$),表示测试数据组数。对于每组测试数据:

第一行包含一个整数 $n$ ($1 \le n \le 5 \times 10^5$)。 下一行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^8$),表示初始序列。 下一行包含 $n$ 个整数 $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^8$),表示最终序列。

保证所有测试数据的 $n$ 之和不超过 $5 \times 10^5$。

输出格式

对于每组测试数据:

如果无法在 $2n + 10$ 次操作内将序列 $a$ 转换为序列 $b$,则输出一行 “No”。

否则,第一行输出 “Yes”。 下一行输出一个整数 $m$ ($0 \le m \le 2n + 10$),表示你想要执行的操作次数。 接下来的 $m$ 行描述你的所有操作。每一行包含三个整数 $i, j$ 和 $x$,表示一次操作。

样例

样例输入 1

3
2
2 2
1 2
4
4 4 4 4
1 1 1 1
5
1 4 3 2 5
2 4 5 4 1

样例输出 1

Yes
5
1 2 10
2 1 19
1 2 7
2 1 3
1 2 2
No
Yes
3
3 4 2
1 3 5
5 1 2

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.