結果
問題 | No.2857 Div Array |
ユーザー | Today03 |
提出日時 | 2024-08-30 05:41:50 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,477 bytes |
コンパイル時間 | 3,535 ms |
コンパイル使用メモリ | 251,976 KB |
実行使用メモリ | 35,740 KB |
最終ジャッジ日時 | 2024-08-30 05:41:58 |
合計ジャッジ時間 | 7,650 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,880 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 3 ms
6,940 KB |
testcase_10 | AC | 126 ms
6,940 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; template <typename T> vector<vector<T>> matMul(const vector<vector<T>> &a, const vector<vector<T>> &b) { int n = a.size(); vector<vector<T>> ret(n, vector<T>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { ret[i][j] += a[i][k] * b[k][j]; } } } return ret; } template <typename T> vector<vector<T>> matPow(vector<vector<T>> a, ll b) { int n = a.size(); vector<vector<T>> ret(n, vector<T>(n)); for (int i = 0; i < n; i++) { ret[i][i] = 1; } while (b) { if (b & 1) { ret = matMul(ret, a); } a = matMul(a, a); b >>= 1; } return ret; } template <ll MOD> struct ModInt { ll value; ModInt(ll x = 0) { if (x >= 0) { value = x % MOD; } else { value = MOD - (-x) % MOD; } } ModInt operator-() const { return ModInt(-value); } ModInt operator+() const { return ModInt(*this); } ModInt &operator+=(const ModInt &other) { value += other.value; if (value >= MOD) { value -= MOD; } return *this; } ModInt &operator-=(const ModInt &other) { value += MOD - other.value; if (value >= MOD) { value -= MOD; } return *this; } ModInt &operator*=(const ModInt other) { value = value * other.value % MOD; return *this; } ModInt &operator/=(ModInt other) { (*this) *= other.inv(); return *this; } ModInt operator+(const ModInt &other) const { return ModInt(*this) += other; } ModInt operator-(const ModInt &other) const { return ModInt(*this) -= other; } ModInt operator*(const ModInt &other) const { return ModInt(*this) *= other; } ModInt operator/(const ModInt &other) const { return ModInt(*this) /= other; } ModInt pow(ll x) const { ModInt ret(1), mul(value); while (x) { if (x & 1) { ret *= mul; } mul *= mul; x >>= 1; } return ret; } ModInt inv() const { return pow(MOD - 2); } bool operator==(const ModInt &other) const { return value == other.value; } bool operator!=(const ModInt &other) const { return value != other.value; } friend ostream &operator<<(ostream &os, const ModInt &x) { return os << x.value; } friend istream &operator>>(istream &is, ModInt &x) { ll v; is >> v; x = ModInt<MOD>(v); return is; } static constexpr ll get_mod() { return MOD; } }; using Mod998 = ModInt<998244353>; using Mod107 = ModInt<1000000007>; using mint = Mod998; int main() { int N, M, K; cin >> N >> M >> K; vector<vector<mint>> mat(M, vector<mint>(M)); for (int i = 1; i <= M; i++) { for (int j = 1; j <= M; j++) { if (abs(M / i - M / j) <= K) { mat[i - 1][j - 1] = 1; } } } mat = matPow(mat, N - 1); mint ans = 0; for (int i = 0; i < M; i++) { for (int j = 0; j < M; j++) { ans += mat[i][j]; } } cout << ans << endl; }