結果

問題 No.2857 Div Array
ユーザー kwm_tkwm_t
提出日時 2024-08-25 14:26:20
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 2,125 bytes
コンパイル時間 5,657 ms
コンパイル使用メモリ 322,364 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-08-25 14:26:32
合計ジャッジ時間 6,245 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 20 ms
6,944 KB
testcase_12 AC 6 ms
6,940 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 19 ms
6,940 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 17 ms
6,940 KB
testcase_18 AC 15 ms
6,940 KB
testcase_19 AC 9 ms
6,944 KB
testcase_20 AC 26 ms
6,940 KB
testcase_21 AC 25 ms
6,944 KB
testcase_22 AC 25 ms
6,948 KB
testcase_23 AC 26 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
using mint = modint998244353;
const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
#include <vector>
template<typename T>
std::vector<vector<T>> matrixMul(const std::vector<std::vector<T>>&A, const std::vector<std::vector<T>>&B) {
	std::vector<vector<T>> C(A.size(), std::vector<T>(B[0].size()));
	for (int i = 0; i < (int)A.size(); ++i) {
		for (int k = 0; k < (int)A[0].size(); ++k) {
			for (int j = 0; j < (int)B[0].size(); ++j) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	return C;
}
template<typename T>
std::vector<std::vector<T>> matrixPow(long long n, std::vector<std::vector<T>> mat) {
	int size = (int)mat.size();
	vector<vector<mint>> mret(size, vector<mint>(size));
	for (int i = 0; i < size; ++i) {
		mret[i][i] = 1;
	}
	while (n > 0) {
		if (1 & n) mret = matrixMul(mat, mret);
		mat = matrixMul(mat, mat);
		n >>= 1;
	}
	return mret;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m, k; cin >> n >> m >> k;
	map<int, int>mp;
	rep2(i, 1, m + 1) {
		mp[m / i]++;
	}
	vector<pair<int, int>>vp;
	for (auto[k, v] : mp)vp.push_back({ k,v });
	int sz = vp.size();
	vector mat(sz, vector<mint>(sz));
	rep(i, sz)rep(j, sz) {
		if (abs(vp[i].first - vp[j].first) > k)continue;
		mat[j][i] += vp[j].second;
	}
	n--;
	mat = matrixPow(n, mat);
	mint ans = 0;
	rep(i, sz)rep(j, sz) {
		ans += vp[i].second * mat[j][i];
	}
	cout << ans.val() << endl;
	return 0;
}
0