結果

問題 No.2817 Competition
ユーザー makichan
提出日時 2024-07-19 23:06:54
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 446 ms / 2,000 ms
コード長 1,229 bytes
コンパイル時間 5,714 ms
コンパイル使用メモリ 320,504 KB
実行使用メモリ 14,720 KB
最終ジャッジ日時 2024-07-19 23:07:05
合計ジャッジ時間 10,872 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};

template<typename T>
void compress(vector<T>&a, bool is_unique=false){
    auto b=a;
    sort(b.begin(),b.end());
    if(is_unique){
        auto p=unique(b.begin(),b.end());
        b.erase(p,b.end());
    }
    for(auto&x:a)x=lower_bound(b.begin(),b.end(),x)-b.begin();
}

int main(){
    int n;
    cin >> n;
    queue<vector<mint>> Q;
    rep(i,0,n){
        ll a;
        cin >> a;
        vector<mint> p(2);
        p[0]=1;
        p[1]=a;
        Q.push(p);
    }
    //rep(i,1,m+1)factorial[i]=factorial[i-1]*i,invfactorial[i]=factorial[i].inv();

    while(Q.size()>1){
        auto a=Q.front();
        Q.pop();
        auto b=Q.front();
        Q.pop();
        Q.push(convolution(a,b));
    }
    auto p=Q.front();
    //for(auto x:p)cout << x.val() << "\n";
    mint ans=0;
    rep(i,1,n+1){
        ans+=p[i]*mint(i).pow(n-i);
    }
    cout << ans.val();
}
0