QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#12403. 最大公约数乘积

Statistics

给定 $n$ 以及序列 $A_{1 \dots n}$ 和 $B_{1 \dots n}$,你需要计算:

$$C_k = \sum_{i=1}^{k} A_{\gcd(i, k)} B_{\gcd(k+1-i, k)}$$

由于输出可能过大,令 $Ans_i$ 表示 $C_i \pmod{998244353}$,你只需要输出 $Ans_1 \text{ xor } Ans_2 \text{ xor } \dots \text{ xor } Ans_n$。

输入格式

第一行包含一个整数 $n$。 第二行包含 $n$ 个整数 $a_{1 \dots n}$。 第三行包含 $n$ 个整数 $b_{1 \dots n}$。

数据范围

$1 \le n \le 5 \times 10^5$ $0 \le a_i, b_i < 998244353$

输出格式

输出答案。

样例

样例输入 1

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

样例输出 1

88

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.