結果

問題 No.3404 形式群法則
コンテスト
ユーザー Kude
提出日時 2025-12-11 11:50:00
言語 C++23
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 778 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,342 ms
コンパイル使用メモリ 335,012 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-12-11 11:50:08
合計ジャッジ時間 7,517 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using mint = atcoder::modint;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long m;
  int p;
  cin >> n >> m >> p;
  mint::set_mod(p);
  vector<mint> am(n), a(n);
  rep(i, n) {
    long long x;
    cin >> x;
    a[i] = x;
  }
  auto mul = [n](const vector<mint>& a, const vector<mint>& b) {
    vector<mint> c(n), ab(n);
    rep(i, n) c[i] = a[i] + b[i];
    rep(i, n) rep(j, n - i) ab[i+j] += a[i] * b[j];
    rep(i, n) rep(j, n - i - 2) c[i+j+2] += c[i] * ab[j];
    return c;
  };
  m %= p;
  while (m) {
    if (m & 1) am = mul(am, a);
    a = mul(a, a);
    m >>= 1;
  }
  rep(i, n) cout << am[i].val() << " \n"[i + 1 == n];
}
0