結果

問題 No.2763 Macaron Gift Box
ユーザー startcpp
提出日時 2024-05-17 21:49:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 1,138 bytes
コンパイル時間 3,158 ms
コンパイル使用メモリ 114,028 KB
実行使用メモリ 814,804 KB
最終ジャッジ日時 2024-12-20 13:34:50
合計ジャッジ時間 15,797 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 MLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

//項の数がO(NlogN)なのですが、分割FFTは...O(N^2)のメモリを使用するのでダメですねorz
#include <iostream>
#include <atcoder/modint>
#include <atcoder/convolution>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
using namespace atcoder;
using mint = modint998244353;

//Π f_i(x) mod x^(n + 1) を求める, i in [l, r), r - l >= 1, f_i(x) mod x^(n + 1) = f_i(x) とする。
vector<mint> multiply(vector<vector<mint>> &f, int l, int r, int n) {
	if (r - l == 1) {
		return f[l];
	}
	vector<mint> res1 = multiply(f, l, (l + r) / 2, n);
	vector<mint> res2 = multiply(f, (l + r) / 2, r, n);
	vector<mint> ret = convolution(res1, res2);
	if (ret.size() > n + 1) ret.resize(n + 1);
	return ret;
}

signed main() {
	int n, K;
	cin >> n >> K;

	vector<vector<mint>> fs;
	for (int i = 1; i <= n; i++) {
		vector<mint> f(n + 1);
		for (int j = 0; i * j <= n && j <= K; j++) {
			f[i * j] = 1;
		}
		fs.push_back(f);
	}

	vector<mint> res = multiply(fs, 0, n, n + 1);
	for (int i = 1; i <= n; i++) {
		cout << res[i].val();
		if (i + 1 <= n) cout << " ";
	}
	cout << endl;
	return 0;
}
0