結果

問題 No.2369 Some Products
ユーザー 👑 NachiaNachia
提出日時 2023-06-30 21:26:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 460 ms / 2,500 ms
コード長 1,106 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 84,276 KB
実行使用メモリ 199,408 KB
最終ジャッジ日時 2023-09-21 15:13:50
合計ジャッジ時間 4,572 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 458 ms
199,116 KB
testcase_03 AC 460 ms
199,108 KB
testcase_04 AC 457 ms
199,240 KB
testcase_05 AC 37 ms
15,540 KB
testcase_06 AC 407 ms
199,408 KB
testcase_07 AC 33 ms
16,920 KB
testcase_08 AC 80 ms
38,600 KB
testcase_09 AC 28 ms
12,360 KB
testcase_10 AC 156 ms
71,524 KB
testcase_11 AC 305 ms
151,004 KB
testcase_12 AC 18 ms
9,068 KB
testcase_13 AC 192 ms
88,212 KB
testcase_14 AC 218 ms
104,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;


int main(){
    int N; cin >> N;
    vector<Modint> P(N);
    rep(i,N){ int a; cin >> a; P[i] = a; }
    vector<vector<Modint>> inv(N+1);
    inv[0].resize(N+1); inv[0][0] = 1;
    rep(i,N){
        auto x = - P[i];
        inv[i+1] = inv[i];
        rep(j,N) inv[i+1][j+1] += inv[i+1][j] * x;
    }
    vector<vector<Modint>> prod(N+1);
    prod[0].resize(N+1); prod[0][0] = 1;
    rep(i,N){
        auto x = P[i];
        prod[i+1] = prod[i];
        for(int j=N-1; j>=0; j--) prod[i+1][j+1] += prod[i+1][j] * x;
    }
    int Q; cin >> Q;
    rep(q,Q){
        int l,r,k; cin >> l >> r >> k; l--;
        Modint ans = 0;
        for(int j=0; j<=k; j++) ans += prod[r][j] * inv[l][k-j];
        cout << ans.val() << '\n';
    }
    return 0;
}
0