結果

問題 No.1164 GCD Products hard
ユーザー dachengzdachengz
提出日時 2022-12-19 17:10:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,211 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 138,700 KB
最終ジャッジ日時 2024-04-29 02:19:39
合計ジャッジ時間 9,551 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 345 ms
92,436 KB
testcase_01 AC 352 ms
96,896 KB
testcase_02 AC 284 ms
89,304 KB
testcase_03 AC 115 ms
73,180 KB
testcase_04 WA -
testcase_05 AC 349 ms
93,252 KB
testcase_06 AC 438 ms
98,304 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 296 ms
89,244 KB
testcase_10 AC 102 ms
71,936 KB
testcase_11 AC 383 ms
91,484 KB
testcase_12 AC 437 ms
97,792 KB
testcase_13 AC 229 ms
86,316 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 309 ms
91,724 KB
testcase_18 AC 281 ms
90,496 KB
testcase_19 WA -
testcase_20 AC 193 ms
81,132 KB
testcase_21 AC 471 ms
101,456 KB
testcase_22 AC 33 ms
52,088 KB
testcase_23 WA -
testcase_24 AC 576 ms
102,728 KB
testcase_25 AC 35 ms
53,240 KB
testcase_26 AC 34 ms
53,684 KB
testcase_27 AC 32 ms
53,284 KB
testcase_28 AC 31 ms
53,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A, B, N = map(int, input().split())

mod = 10 ** 9 + 7
mod2 = 10 ** 9 + 6

B2 = B // 2
B21 = B2 + 1
cnt = [0] * max(A, B21)    
A -= 1

ret = 1
for i in range(B, max(B2, A), -1):
    ret = ret * i % mod

lastBi = lastval = 0
tmpprod = 1
for i in range(max(B2, A), A, -1):
    Bi = B // i
    if Bi != lastBi:
        ret = ret * pow(tmpprod, lastval, mod) % mod
        tmpprod, lastBi = i, Bi
        lastval = pow(Bi, N, mod2)
        for n in range(i + i, B21, i):
            lastval -= cnt[n]
        lastval = (lastval - Bi + Bi // 2) % mod2
    else:
        tmpprod = tmpprod * i % mod
    cnt[i] = lastval
ret = ret * pow(tmpprod, lastval, mod) % mod

lastAi = lastBi = lastval = 0
tmpprod = 1
for i in range(A, 1, -1):
    Bi = B // i
    Ai = A // i
    if Ai == Bi:
        continue
    if Bi != lastBi or Ai != lastAi:
        ret = ret * pow(tmpprod, lastval, mod) % mod
        tmpprod, lastAi, lastBi = i, Ai, Bi
        lastval = pow(Bi - Ai, N, mod2)
        for n in range(i + i, B21, i):
            lastval -= cnt[n]
        lastval = (lastval - Bi + Bi // 2) % mod2
    else:
        tmpprod = tmpprod * i % mod
    cnt[i] = lastval
ret = ret * pow(tmpprod, lastval, mod) % mod
print(ret)
0