結果

問題 No.3404 形式群法則
コンテスト
ユーザー cho435
提出日時 2025-12-11 22:51:19
言語 C++17
(gcc 13.3.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 1,260 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,404 ms
コンパイル使用メモリ 260,164 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-11 22:51:25
合計ジャッジ時間 6,269 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)

template <class T> bool chmin(T& x, T y) {
	return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
	return x < y ? (x = y, true) : false;
}

struct io_setup {
	io_setup() {
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		cout << fixed << setprecision(15);
	}
} io_setup;

using mint = atcoder::modint;

vector<mint> comp(vector<mint> a, vector<mint> b, int mx) {
	vector<mint> v(mx, 0);
	rep(i, 0, mx) rep(j, 0, mx - i) {
		v[i + j] = a[i] * b[j];
	}
	vector<mint> res(mx, 0);
	rep(i, 0, mx) {
		res[i] = a[i] + b[i];
		rep(j, 0, i - 1) {
			res[i] += res[j] * v[i - 2 - j];
		}
	}
	return res;
}

void solve() {
	ll n, m, p;
	cin >> n >> m >> p;
	mint::set_mod(p);
	vector<mint> a(n);
	rep(i, 0, n) {
		ll x;
		cin >> x;
		a[i] = x;
	}
	vector<vector<mint>> pw(60);
	pw[0] = a;
	rep(i, 1, 60) pw[i] = comp(pw[i - 1], pw[i - 1], n);
	vector<mint> ans(n, 0);
	rep(i, 0, 60) {
		if ((m >> i) & 1) ans = comp(ans, pw[i], n);
	}
	rep(i, 0, n) cout << ans[i].val() << ' ';
	cout << '\n';
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) solve();
}
0