結果

問題 No.2365 Present of good number
ユーザー shobonvipshobonvip
提出日時 2023-06-30 00:08:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,450 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 80,392 KB
最終ジャッジ日時 2023-09-21 14:40:19
合計ジャッジ時間 6,679 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,252 KB
testcase_01 AC 73 ms
70,992 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 92 ms
77,636 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 73 ms
70,908 KB
testcase_18 AC 71 ms
70,740 KB
testcase_19 AC 72 ms
71,156 KB
testcase_20 AC 71 ms
71,220 KB
testcase_21 AC 93 ms
76,528 KB
testcase_22 WA -
testcase_23 AC 124 ms
77,300 KB
testcase_24 AC 88 ms
76,228 KB
testcase_25 AC 117 ms
76,804 KB
testcase_26 AC 95 ms
77,296 KB
testcase_27 AC 92 ms
77,368 KB
testcase_28 AC 93 ms
76,108 KB
testcase_29 AC 101 ms
77,532 KB
testcase_30 AC 95 ms
76,848 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 93 ms
77,352 KB
testcase_37 AC 99 ms
77,944 KB
testcase_38 AC 94 ms
77,476 KB
testcase_39 AC 95 ms
77,300 KB
testcase_40 AC 100 ms
77,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod1 = 1000000007
mod2 = mod1 - 1

# 高々 log オーダー回のあと, 2^a * 3^b になる.
# a, b を 10^9 + 6 で割った余りを保持すればよい.

n, k = map(int,input().split())

mx = n + 5
p = [0] * (mx+1)
dp = [0] * (mx+1)

for i in range(2, mx+1):
	if p[i] == 0:
		for j in range(2*i, mx+1, i):
			p[j] = i

dp[n] = 1
for i in range(mx,1,-1):
	if p[i] != 0 and dp[i] != 0:
		dp[i // p[i]] = (dp[i // p[i]] + dp[i]) % mod2
		dp[p[i]] = (dp[p[i]] + dp[i]) % mod2
		dp[i] = 0

for num in range(min(k, 70)):
	for i in range(mx-1,0,-1):
		dp[i+1] = dp[i]
	for i in range(mx,1,-1):
		if p[i] != 0 and dp[i] != 0:
			dp[i // p[i]] = (dp[i // p[i]] + dp[i]) % mod2
			dp[p[i]] = (dp[p[i]] + dp[i]) % mod2
			dp[i] = 0

k -= min(k, 70)

if k >= 1:
	for i in range(0, mx+1):
		if i == 2 or i == 3: continue
		print(i, dp[i])
		assert dp[i] == 0
	mat = [[[0] * 2 for i in range(2)] for j in range(60)]
	mat[0][0][1] = 2
	mat[0][1][0] = 1
	ar = [dp[2], dp[3]]
	for num in range(59):
		for i in range(2):
			for j in range(2):
				for l in range(2):
					mat[num+1][i][j] += mat[num][i][l] * mat[num][l][j]
					mat[num+1][i][j] %= mod2
	for num in range(60):
		if (k >> num & 1):
			nar = [0, 0]
			for i in range(2):
				for j in range(2):
					nar[i] += mat[num][i][j] * ar[j]
					nar[i] %= mod2
			ar = nar
	dp[2] = ar[0]
	dp[3] = ar[1]

ans = 1
for i in range(2, mx+1):
	if dp[i] != 0:
		ans *= pow(i, dp[i], mod1)
		ans %= mod1

print(ans)
0