結果
問題 | No.2318 Phys Bone Maker |
ユーザー |
|
提出日時 | 2023-02-26 02:45:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,764 ms / 3,000 ms |
コード長 | 1,994 bytes |
コンパイル時間 | 336 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 94,316 KB |
最終ジャッジ日時 | 2024-09-18 12:56:47 |
合計ジャッジ時間 | 25,644 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
import sysfrom collections import deque, Counterfrom math import gcd, log10, pi, sqrt, ceilfrom bisect import bisect, bisect_left, bisect_right, insortfrom typing import Iterable, TypeVar, Union, Tuple, Iterator, Listimport copyimport heapqimport itertoolsimport mathimport randomfrom fractions import Fractionfrom functools import lru_cache, partial, cmp_to_keyimport operatorimport pypyjitpypyjit.set_param('max_unroll_recursion=-1')input = sys.stdin.readlinesys.setrecursionlimit(10000000)mod = 998244353INF = 1 << 61DIFF = 10 ** -9DX = [1, 0, -1, 0, 1, 1, -1, -1]DY = [0, 1, 0, -1, 1, -1, 1, -1]def read_values(): return map(int, input().split())def read_index(): return map(lambda x: int(x) - 1, input().split())def read_list(): return list(read_values())def read_lists(N): return [read_list() for _ in range(N)]def main():N = int(input())T = {}for n in range(2, int(N ** 0.5) + 1):while N % n == 0:T[n] = T.get(n, 0) + 1N //= nif N > 1:T[N] = T.get(N, 0) + 1T = list(T.items())X = {}V = set()def f(s, S):if len(S) == len(T):V.add(s)X[s] = (tuple(S))returnk, v = T[len(S)]S.append(0)for _ in range(v + 1):f(s, S)s *= kS[-1] += 1S.pop()s //= k ** vf(1, [])N = len(V)V = sorted(list(V))X = [X[v] for v in V]dp = [0] * Ndp[0] = 1for i in range(N):for j in range(i + 1, N):r = 1for x1, x2 in zip(X[i], X[j]):if x2 > x1:continueelif x2 == x1:r *= x1 + 1r %= modelse:breakelse:dp[j] += dp[i] * r % moddp[j] %= modprint(dp[-1])if __name__ == "__main__":main()