結果
問題 | No.1973 Divisor Sequence |
ユーザー | terasa |
提出日時 | 2022-06-11 11:18:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 249 ms / 2,000 ms |
コード長 | 2,194 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 82,336 KB |
実行使用メモリ | 77,696 KB |
最終ジャッジ日時 | 2024-09-21 20:11:09 |
合計ジャッジ時間 | 3,003 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
61,696 KB |
testcase_01 | AC | 46 ms
55,040 KB |
testcase_02 | AC | 67 ms
65,664 KB |
testcase_03 | AC | 57 ms
61,952 KB |
testcase_04 | AC | 65 ms
64,256 KB |
testcase_05 | AC | 59 ms
61,056 KB |
testcase_06 | AC | 59 ms
63,744 KB |
testcase_07 | AC | 69 ms
63,616 KB |
testcase_08 | AC | 69 ms
63,744 KB |
testcase_09 | AC | 66 ms
64,512 KB |
testcase_10 | AC | 78 ms
67,328 KB |
testcase_11 | AC | 65 ms
64,896 KB |
testcase_12 | AC | 68 ms
63,616 KB |
testcase_13 | AC | 62 ms
65,664 KB |
testcase_14 | AC | 88 ms
73,512 KB |
testcase_15 | AC | 69 ms
66,816 KB |
testcase_16 | AC | 66 ms
64,768 KB |
testcase_17 | AC | 77 ms
67,328 KB |
testcase_18 | AC | 83 ms
70,656 KB |
testcase_19 | AC | 75 ms
66,688 KB |
testcase_20 | AC | 68 ms
64,128 KB |
testcase_21 | AC | 70 ms
63,360 KB |
testcase_22 | AC | 65 ms
64,896 KB |
testcase_23 | AC | 249 ms
77,696 KB |
testcase_24 | AC | 90 ms
77,236 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, N, A, p): self.N = N self.A = 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(v + 1, 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)