結果

問題 No.2717 Sum of Subarray of Subsequence
ユーザー nonon
提出日時 2024-04-06 09:09:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 194,924 KB
最終ジャッジ日時 2025-02-20 22:28:34
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int N;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N;
    if(N==1)
    {
        int A;
        cin>>A;
        cout<<A<<endl;
        return 0;
    }
    if(N==2)
    {
        int A,B;
        cin>>A>>B;
        cout<<(mint(3)*(A+B)).val()<<endl;
        return 0;
    }
    mint ans=0;
    for(int i=N;i--;)
    {
        int A;
        cin>>A;
        ans+=mint(A)*(i+2)*(N-i+1)*mint(2).pow(N-3);
    }
    cout<<ans.val()<<endl;
}
0