結果
問題 | No.1973 Divisor Sequence |
ユーザー | terasa |
提出日時 | 2022-06-11 11:26:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 263 ms / 2,000 ms |
コード長 | 2,189 bytes |
コンパイル時間 | 368 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 77,440 KB |
最終ジャッジ日時 | 2024-09-21 20:20:03 |
合計ジャッジ時間 | 3,513 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
61,824 KB |
testcase_01 | AC | 49 ms
54,528 KB |
testcase_02 | AC | 78 ms
65,664 KB |
testcase_03 | AC | 63 ms
61,568 KB |
testcase_04 | AC | 72 ms
63,872 KB |
testcase_05 | AC | 65 ms
61,056 KB |
testcase_06 | AC | 71 ms
63,488 KB |
testcase_07 | AC | 74 ms
63,232 KB |
testcase_08 | AC | 78 ms
63,360 KB |
testcase_09 | AC | 75 ms
63,616 KB |
testcase_10 | AC | 81 ms
66,688 KB |
testcase_11 | AC | 69 ms
64,000 KB |
testcase_12 | AC | 74 ms
63,488 KB |
testcase_13 | AC | 70 ms
65,152 KB |
testcase_14 | AC | 102 ms
73,472 KB |
testcase_15 | AC | 77 ms
66,688 KB |
testcase_16 | AC | 73 ms
64,000 KB |
testcase_17 | AC | 86 ms
67,328 KB |
testcase_18 | AC | 95 ms
70,272 KB |
testcase_19 | AC | 84 ms
66,048 KB |
testcase_20 | AC | 78 ms
64,000 KB |
testcase_21 | AC | 76 ms
63,872 KB |
testcase_22 | AC | 72 ms
64,384 KB |
testcase_23 | AC | 263 ms
77,440 KB |
testcase_24 | AC | 104 ms
76,928 KB |
ソースコード
import sys import pypyjit import itertools import heapq import math from collections import deque, defaultdict import bisect input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) pypyjit.set_param('max_unroll_recursion=-1') def index_lt(a, x): 'return largest index s.t. A[i] < x or -1 if it does not exist' return bisect.bisect_left(a, x) - 1 def index_le(a, x): 'return largest index s.t. A[i] <= x or -1 if it does not exist' return bisect.bisect_right(a, x) - 1 def index_gt(a, x): 'return smallest index s.t. A[i] > x or len(a) if it does not exist' return bisect.bisect_right(a, x) def index_ge(a, x): 'return smallest index s.t. A[i] >= x or len(a) if it does not exist' return bisect.bisect_left(a, x) class Matpow: def __init__(self, A, p): self.A = A self.N = len(A) self.p = p self.digit = 60 self.doubling = [None] * self.digit self.doubling[0] = A for i in range(1, self.digit): self.doubling[i] = self.mul(self.doubling[i - 1], self.doubling[i - 1]) def pow(self, n): E = [[1 if i == j else 0 for j in range(self.N)] for i in range(self.N)] acc = E for k in range(self.digit): if n & (1 << k): acc = self.mul(acc, self.doubling[k]) return acc def mul(self, A, B): C = [[0 for _ in range(self.N)] for _ in range(self.N)] for i in range(self.N): for j in range(self.N): for k in range(self.N): C[i][j] += A[i][k] * B[k][j] C[i][j] %= self.p return C N, M = map(int, input().split()) mod = 10 ** 9 + 7 n = M factors = defaultdict(int) for i in range(2, M + 1): if i * i > M: break while n % i == 0: factors[i] += 1 n //= i if n > 1: factors[n] += 1 ans = 1 for v in factors.values(): A = [] for i in range(v + 1): a = [1] * (v + 1 - i) + [0] * i A.append(a) An = Matpow(A, mod).pow(N - 1) acc = 0 for i in range(v + 1): for j in range(v + 1): acc += An[i][j] ans *= acc ans %= mod print(ans)