Effects of Anti Pimples—CF1877D
难度大概在1500~1600。
这个D题比C题简单,以后遇到做不出来的题要及时换题。
题目不难,就不写思路了。
C o d e Code Code
#include <bits/stdc++.h>
#define int long long
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
using namespace std;
using PII = pair<int, int>;
using i128 = __int128;
const int N = 2e5 + 10;
const int mod = 998244353;
int n;
int a[N], mx[N];
void solve() {
cin >> n;
for (int i = 1; i <= n; i ++) cin >> a[i];
for (int i = 1; i <= n; i ++) {
int max_a = -1;
for (int j = i; j <= n; j += i) {
max_a = max(max_a, a[j]);
}
mx[i] = max_a;
}
sort(mx + 1, mx + n + 1);
vector<int> power(n + 1);
power[0] = 1;
for (int i = 1; i <= n; i ++) {
power[i] = power[i - 1] * 2 % mod;
}
int res = 0;
for (int i = 1; i <= n; i ++) {
/*
res += mx[i] * num;
num = 在i - 1个数字中任选x个数字的选法
(0 <= x <= i - 1)
*/
res = (res + (mx[i] * power[i - 1] % mod)) % mod;
}
cout << " ";
cout << res << "\n";
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T; cin.get();
while (T --) solve();
return 0;
}