結果

問題 No.1325 Subsequence Score
ユーザー shinchanshinchan
提出日時 2020-12-27 14:31:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,701 bytes
コンパイル時間 3,433 ms
コンパイル使用メモリ 206,648 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-08 21:59:50
合計ジャッジ時間 5,840 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 64 ms
11,628 KB
testcase_14 AC 21 ms
6,676 KB
testcase_15 AC 55 ms
12,416 KB
testcase_16 AC 62 ms
11,180 KB
testcase_17 AC 30 ms
7,084 KB
testcase_18 AC 18 ms
6,676 KB
testcase_19 AC 65 ms
11,676 KB
testcase_20 AC 10 ms
6,676 KB
testcase_21 AC 25 ms
6,796 KB
testcase_22 AC 30 ms
7,120 KB
testcase_23 AC 66 ms
11,688 KB
testcase_24 AC 66 ms
11,688 KB
testcase_25 AC 66 ms
11,688 KB
testcase_26 AC 65 ms
11,688 KB
testcase_27 AC 66 ms
11,688 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


///////modint
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> v(n);
    vector<mint> a;
    rep(i, n){
        cin >> v[i];
        a.pb(mint(v[i]));
    }
    mint ans = mint(0);
    if(n == 1){
        cout << a[0].x << endl; 
        return 0;
    } 
    rep(i, n){
        ans += a[i] * mint(i + 2);
    }
    ans *= mint(2).pow(n - 2);
    cout << ans.x << endl;
    return 0;
}


0