結果

問題 No.3404 形式群法則
コンテスト
ユーザー t98slider
提出日時 2025-12-11 01:46:00
言語 C++17
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 1,002 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,960 ms
コンパイル使用メモリ 255,528 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-11 01:46:05
合計ジャッジ時間 5,479 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, p, v;
    cin >> n >> m >> p;
    mint::set_mod(p);
    vector<mint> a(n + 1), ans(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> v;
        a[i] = v;
    }
    auto mul = [&](vector<mint> &lhs, vector<mint> &rhs){
        vector<mint> res(n + 1), c(n + 1);
        for(int i = 1; i <= n; i++){
            for(int j = 1; i + j <= n; j++){
                c[i + j] += lhs[i] * rhs[j];
            }
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j < i; j++){
                res[i] += res[j] * c[i - j];
            }
            res[i] += lhs[i] + rhs[i];
        }
        return res;
    };
    while(m){
        if(m & 1) ans = mul(ans, a);
        a = mul(a, a);
        m /= 2;
    }
    for(int i = 1; i <= n; i++) cout << ans[i].val() << (i == n ? '\n' : ' ');
}
0