結果

問題 No.2857 Div Array
ユーザー prin_kemkemprin_kemkem
提出日時 2024-08-25 15:35:35
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 3,329 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 104,660 KB
最終ジャッジ日時 2024-08-25 15:35:42
合計ジャッジ時間 7,319 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
87,632 KB
testcase_01 AC 99 ms
81,468 KB
testcase_02 AC 109 ms
81,400 KB
testcase_03 AC 101 ms
81,160 KB
testcase_04 AC 98 ms
81,400 KB
testcase_05 AC 96 ms
81,380 KB
testcase_06 AC 100 ms
81,316 KB
testcase_07 AC 105 ms
81,496 KB
testcase_08 AC 101 ms
81,192 KB
testcase_09 AC 118 ms
81,528 KB
testcase_10 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
# from functools import cache
# import copy
from itertools import combinations, permutations, product, accumulate, groupby, chain
# from more_itertools import distinct_permutations
from heapq import heapify, heappop, heappush
import math
import bisect
from pprint import pprint
from random import randint, shuffle, randrange
import sys
# sys.setrecursionlimit(200000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
mod2 = 998244353
def ceil_div(x, y): return -(-x//y)

#################################################   

class Matrix():
    def __init__(self, mat, mod=None):
        self.mat = mat
        self.n = len(mat)
        self.m = len(mat[0])
        self.mod = mod
    def __mul__(self, other):
        ret = Matrix([[0]*other.m for _ in range(self.n)], self.mod)
        for i in range(self.n):
            for j in range(other.m):
                for k in range(self.m):
                    ret[i][j] += self.mat[i][k]*other.mat[k][j]
                    if self.mod is not None: ret[i][j] %= self.mod
        return ret
    def __add__(self, other):
        ret = Matrix([[self.mat[i][j] for j in range(self.m)] for i in range(self.n)], self.mod)
        for i in range(other.n):
            for j in range(other.m):
                ret[i][j] += other.mat[i][j]
                if self.mod is not None: ret[i][j] %= self.mod
        return ret
    def __sub__(self, other):
        ret = Matrix([[self.mat[i][j] for j in range(self.m)] for i in range(self.n)], self.mod)
        for i in range(other.n):
            for j in range(other.m):
                ret[i][j] -= other.mat[i][j]
                if self.mod is not None: ret[i][j] %= self.mod
        return ret
    def __pow__(self, scalar):
        a = Matrix([[self.mat[i][j] for j in range(self.m)] for i in range(self.n)], self.mod)
        ret = Matrix.e(self.n, self.mod)
        while scalar:
            if scalar&1:
                ret *= a
            a *= a
            scalar >>= 1
        return ret
    def scalar_mul(self, a):
        ret = Matrix([[self.mat[i][j] for j in range(self.m)] for i in range(self.n)], self.mod)
        for i in range(self.n):
            for j in range(self.m):
                ret[i][j] *= a
                if self.mod is not None: ret[i][j] %= self.mod
        return ret
    def __repr__(self) -> str:
        return self.mat.__repr__()
    def __getitem__(self, i):
        return self.mat[i]
    def __setitem__(self, i, x):
        self.mat[i] = x
    def __len__(self):
        return len(self.mat)
    def t(self):
        return Matrix([list(column) for column in zip(*self.mat)], self.mod)
    def turn(matrix):
        if type(matrix) != 'Matrix':
            return Matrix([list(column) for column in zip(*matrix)])
        return Matrix([list(column) for column in zip(*matrix.mat)], matrix.mod)
    def e(size, mod):
        return Matrix([[i == j for j in range(size)] for i in range(size)], mod)

N, M, K = map(int, input().split())
A = [[False]*(M+1) for _ in range(M+1)]
for i in range(1, M+1):
    for j in range(1, M+1):
        A[i][j] = abs(M//i - M//j) <= K
dp = [[0]+[1]*M]
dp = Matrix(dp, mod2)
A = Matrix(A, mod2)
dp = dp*A**(N-1)
ans = 0
for a in dp[0]:
    ans += a
    ans %= mod2
print(ans)
0