CF1876B.Effects of Anti Pimples
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Chaneka has an array [a1,a2,…,an]. Initially, all elements are white. Chaneka will choose one or more different indices and colour the elements at those chosen indices black. Then, she will choose all white elements whose indices are multiples of the index of at least one black element and colour those elements green. After that, her score is the maximum value of ai out of all black and green elements.
There are 2n−1 ways for Chaneka to choose the black indices. Find the sum of scores for all possible ways Chaneka can choose the black indices. Since the answer can be very big, print the answer modulo 998244353.
Chaneka 有一个数组 [a1,a2,…,an]。初始时,所有元素均为白色。Chaneka 将选择一个或多个互不相同的下标,并将这些下标对应位置的元素染成黑色。接着,她将找出所有满足以下条件的白色元素:其下标是至少一个黑色元素下标的倍数,并将这些元素染成绿色。此后,她的得分为所有黑色和绿色元素中 ai 的最大值。
Chaneka 选择黑色下标的方式共有 2n−1 种。求对所有可能的黑色下标选择方式,其对应得分的总和。由于答案可能非常大,请将结果对 998244353 取模后输出。
输入格式
The first line contains a single integer n (1≤n≤105) — the size of array a.
The second line contains n integers a1,a2,a3,…,an (0≤ai≤105).
第一行包含一个整数 n(1≤n≤105)—— 数组 a 的大小。
第二行包含 n 个整数 a1,a2,a3,…,an(0≤ai≤105)。
输出格式
An integer representing the sum of scores for all possible ways Chaneka can choose the black indices, modulo 998244353.
一个整数,表示 Chaneka 选择所有可能的黑色下标方案所得分数之和,对 998244353 取模的结果。
输入输出样例
输入#1
4 19 14 19 9
输出#1
265
输入#2
1 0
输出#2
0
输入#3
15 90000 9000 99000 900 90900 9900 99900 90 90090 9090 99090 990 90990 9990 99990
输出#3
266012571
说明/提示
In the first example, below are the 15 possible ways to choose the black indices:
- Index 1 is black. Indices 2, 3, and 4 are green. Maximum value among them is 19.
- Index 2 is black. Index 4 is green. Maximum value among them is 14.
- Index 3 is black. Maximum value among them is 19.
- Index 4 is black. Maximum value among them is 9.
- Indices 1 and 2 are black. Indices 3 and 4 are green. Maximum value among them is 19.
- Indices 1 and 3 are black. Indices 2 and 4 are green. Maximum value among them is 19.
- Indices 1 and 4 are black. Indices 2 and 3 are green. Maximum value among them is 19.
- Indices 2 and 3 are black. Index 4 is green. Maximum value among them is 19.
- Indices 2 and 4 are black. Maximum value among them is 14.
- Indices 3 and 4 are black. Maximum value among them is 19.
- Indices 1, 2, and 3 are black. Index 4 is green. Maximum value among them is 19.
- Indices 1, 2, and 4 are black. Index 3 is green. Maximum value among them is 19.
- Indices 1, 3, and 4 are black. Index 2 is green. Maximum value among them is 19.
- Indices 2, 3, and 4 are black. Maximum value among them is 19.
- Indices 1, 2, 3, and 4 are black. Maximum value among them is 19.
The total sum is 19+14+19+9+19+19+19+19+14+19+19+19+19+19+19=265.
在第一个样例中,以下是选择黑色下标的 15 种可能方式:
- 下标 1 为黑色,下标 2、3 和 4 为绿色,其中最大值为 19。
- 下标 2 为黑色,下标 4 为绿色,其中最大值为 14。
- 下标 3 为黑色,其中最大值为 19。
- 下标 4 为黑色,其中最大值为 9。
- 下标 1 和 2 为黑色,下标 3 和 4 为绿色,其中最大值为 19。
- 下标 1 和 3 为黑色,下标 2 和 4 为绿色,其中最大值为 19。
- 下标 1 和 4 为黑色,下标 2 和 3 为绿色,其中最大值为 19。
- 下标 2 和 3 为黑色,下标 4 为绿色,其中最大值为 19。
- 下标 2 和 4 为黑色,其中最大值为 14。
- 下标 3 和 4 为黑色,其中最大值为 19。
- 下标 1、2 和 3 为黑色,下标 4 为绿色,其中最大值为 19。
- 下标 1、2 和 4 为黑色,下标 3 为绿色,其中最大值为 19。
- 下标 1、3 和 4 为黑色,下标 2 为绿色,其中最大值为 19。
- 下标 2、3 和 4 为黑色,其中最大值为 19。
- 下标 1、2、3 和 4 均为黑色,其中最大值为 19。
总和为 19+14+19+9+19+19+19+19+14+19+19+19+19+19+19=265。
输入解题思路,AI测评打分。不知道怎么写?