結果
問題 | No.1973 Divisor Sequence |
ユーザー | terasa |
提出日時 | 2022-06-11 00:22:07 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,276 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,824 KB |
実行使用メモリ | 86,884 KB |
最終ジャッジ日時 | 2024-09-21 07:30:23 |
合計ジャッジ時間 | 4,987 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
70,324 KB |
testcase_01 | AC | 44 ms
55,808 KB |
testcase_02 | AC | 105 ms
73,988 KB |
testcase_03 | AC | 68 ms
66,248 KB |
testcase_04 | AC | 103 ms
74,324 KB |
testcase_05 | AC | 68 ms
61,092 KB |
testcase_06 | AC | 72 ms
68,400 KB |
testcase_07 | AC | 98 ms
66,852 KB |
testcase_08 | AC | 91 ms
67,224 KB |
testcase_09 | AC | 99 ms
73,316 KB |
testcase_10 | AC | 122 ms
72,132 KB |
testcase_11 | AC | 92 ms
74,160 KB |
testcase_12 | AC | 96 ms
67,048 KB |
testcase_13 | AC | 72 ms
67,384 KB |
testcase_14 | TLE | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
ソースコード
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 def divs(n): d = [] for i in range(1, n + 1): if i * i > n: break if i * i == n: d.append(i) break if n % i == 0: d.append(i) d.append(n // i) return sorted(d) D = divs(M) idx = {} for i, n in enumerate(D): idx[n] = i A = [] for d in D: a = [0] * len(D) for n in divs(M // d): a[idx[n]] = 1 A.append(a) An = Matpow(len(D), A, mod).pow(N - 1) ans = 0 for i in range(len(D)): for j in range(len(D)): ans += An[i][j] ans %= mod print(ans)