#P14009. 「florr IO Round 1」数字游戏

    ID: 13355 远端评测题 5000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>线段树洛谷原创O2优化分治莫比乌斯反演洛谷月赛整除分块

「florr IO Round 1」数字游戏

Description

Given a positive integer nn and a sequence of positive integers aa, where nn represents the length of the sequence aa.

We define the weight of an interval [l,r][l, r] as f(l,r)f(l, r), where:

$$f(l, r) = \sum_{b_1=1}^{a_l} \sum_{b_2=1}^{a_{l+1}} \sum_{b_3=1}^{a_{l+2}} \dots \sum_{b_{r-l+1}=1}^{a_r} [\gcd(b_1, b_2, b_3, \dots, b_{r-l+1}) = 1]$$

Find the sum of the weights of all intervals, that is, compute:

l=1nr=lnf(l,r)\sum_{l=1}^{n} \sum_{r=l}^{n} f(l, r)

Output the answer modulo 998244353998244353.

Input Format

The first line contains an integer nn.

The second line contains nn integers representing the sequence aa.

Output Format

Output a single line containing the answer.

2
1 2
4
5
2 4 4 5 4 
1301
10
1 7 5 5 7 6 9 2 4 8 
10816520

Hint

Data Range

This problem uses bundled tests.

Subtask ID nn\le aia_i\le Score
1 5 10
2 200 100 30
3 2000 1000
4 7×1047\times 10^4

Translated by ChatGPT 4.1