結果

問題 No.1164 GCD Products hard
ユーザー dachengzdachengz
提出日時 2022-12-19 16:20:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 898 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 141,560 KB
最終ジャッジ日時 2024-04-29 02:18:13
合計ジャッジ時間 49,018 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,190 ms
92,704 KB
testcase_01 TLE -
testcase_02 AC 1,691 ms
88,388 KB
testcase_03 AC 627 ms
73,292 KB
testcase_04 WA -
testcase_05 AC 2,248 ms
92,772 KB
testcase_06 AC 2,180 ms
98,784 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1,625 ms
88,832 KB
testcase_10 AC 590 ms
71,720 KB
testcase_11 AC 1,573 ms
92,072 KB
testcase_12 TLE -
testcase_13 AC 1,519 ms
85,620 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2,140 ms
91,604 KB
testcase_18 AC 2,022 ms
91,364 KB
testcase_19 WA -
testcase_20 AC 1,007 ms
78,932 KB
testcase_21 TLE -
testcase_22 AC 32 ms
53,284 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 34 ms
53,360 KB
testcase_26 AC 31 ms
53,612 KB
testcase_27 AC 31 ms
52,372 KB
testcase_28 AC 31 ms
52,312 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
lastBi = lastval = 1
for i in range(B2, A, -1):
    Bi = B // i
    if Bi != lastBi:
        lastBi = Bi
        lastval = pow(Bi, N, mod2)
        for n in range(i + i, B21, i):
            lastval -= cnt[n]
        lastval = (lastval - Bi + Bi // 2) % mod2
    cnt[i] = lastval
lastAi = lastBi = lastval = 0
for i in range(A, 1, -1):
    Bi = B // i
    Ai = A // i
    if Bi != lastBi or Ai != lastAi:
        lastAi, lastBi = 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
    cnt[i] = lastval
ret = 1
for i in range(B, B // 2, -1):
    ret = ret * i % mod
for i in range(B // 2, 1, -1):
    ret = ret * pow(i, cnt[i], mod) % mod
print(ret)
0