結果
問題 | No.2717 Sum of Subarray of Subsequence |
ユーザー |
|
提出日時 | 2024-04-05 21:44:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 138 ms / 2,000 ms |
コード長 | 2,606 bytes |
コンパイル時間 | 2,182 ms |
コンパイル使用メモリ | 195,696 KB |
最終ジャッジ日時 | 2025-02-20 21:06:08 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include "bits/stdc++.h"using namespace std;#define all(x) x.begin(),x.end()template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << " " << p.second; }template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream&operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }#ifdef LOCAL#include "debug.h"#else#define debug(...) 42#define ASSERT(...) 42#endiftypedef long long ll;typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pi;const int oo = 1e9;const long long MD = 998244353;template<long long MOD=MD> struct mdint {int d;mdint () {d=0;}mdint (long long _d) : d(_d%MOD){if(d<0) d+=MOD;};friend mdint& operator+=(mdint& a, const mdint& o) {a.d+=o.d; if(a.d>=MOD) a.d-=MOD;return a;}friend mdint& operator-=(mdint& a, const mdint& o) {a.d-=o.d; if(a.d<0) a.d+=MOD;return a;}friend mdint& operator*=(mdint& a, const mdint& o) {return a = mdint((ll)a.d*o.d);}mdint operator*(const mdint& o) const {mdint res = *this;res*=o;return res;}mdint operator+(const mdint& o) const {mdint res = *this;res+=o;return res;}mdint operator-(const mdint& o) const {mdint res = *this;res-=o;return res;}mdint operator^(long long b) const {mdint tmp = 1;mdint power = *this;while(b) {if(b&1) {tmp = tmp*power;}power = power*power;b/=2;}return tmp;}friend mdint operator/=(mdint& a, const mdint& o) {a *= (o^(MOD-2));return a;}mdint operator/(const mdint& o) {mdint res = *this;res/=o;return res;}bool operator==(const mdint& o) { return d==o.d;}bool operator!=(const mdint& o) { return d!=o.d;}friend istream& operator>>(istream& c, mdint& a) {return c >> a.d;}friend ostream& operator<<(ostream& c, const mdint& a) {return c << a.d;}};using mint = mdint<MD>;int main() {ios_base::sync_with_stdio(false);cin.tie(NULL);int n; cin >> n;mint ans=0;auto f = [&](int v) {return ((mint(2)^v) / 2)*(v+2);};for(int i=0;i<n;++i) {int v; cin >> v;ans+=f(i)*f(n-1-i)*v;}cout << ans << '\n';}