結果

問題 No.1164 GCD Products hard
ユーザー rlangevinrlangevin
提出日時 2024-04-14 11:34:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,299 ms / 2,500 ms
コード長 626 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,128 KB
実行使用メモリ 245,212 KB
最終ジャッジ日時 2024-04-14 11:35:19
合計ジャッジ時間 22,138 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 898 ms
191,144 KB
testcase_01 AC 1,011 ms
205,188 KB
testcase_02 AC 808 ms
174,496 KB
testcase_03 AC 250 ms
100,284 KB
testcase_04 AC 256 ms
103,616 KB
testcase_05 AC 918 ms
190,808 KB
testcase_06 AC 1,064 ms
218,232 KB
testcase_07 AC 1,051 ms
222,704 KB
testcase_08 AC 1,083 ms
222,092 KB
testcase_09 AC 715 ms
175,120 KB
testcase_10 AC 250 ms
98,472 KB
testcase_11 AC 797 ms
186,168 KB
testcase_12 AC 1,124 ms
218,100 KB
testcase_13 AC 616 ms
156,548 KB
testcase_14 AC 650 ms
175,132 KB
testcase_15 AC 1,094 ms
223,932 KB
testcase_16 AC 759 ms
187,280 KB
testcase_17 AC 880 ms
188,056 KB
testcase_18 AC 750 ms
177,376 KB
testcase_19 AC 285 ms
104,576 KB
testcase_20 AC 423 ms
125,232 KB
testcase_21 AC 1,160 ms
223,852 KB
testcase_22 AC 38 ms
52,996 KB
testcase_23 AC 1,043 ms
245,212 KB
testcase_24 AC 1,299 ms
243,692 KB
testcase_25 AC 37 ms
52,824 KB
testcase_26 AC 37 ms
52,540 KB
testcase_27 AC 38 ms
53,392 KB
testcase_28 AC 37 ms
53,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import ceil, sqrt
def Sieve(n):
    lst = [True] * (n + 1)
    lst[0] = lst[1] = False
    S = set()
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.add(i)
    return S


A, B, N = map(int, input().split())
mod = 10**9 + 7
ans = 1
for p in Sieve(B):
    now = p
    cnt = 0
    while now <= B:
        v = B // now - (A - 1) // now
        cnt += pow(v, N, mod - 1)
        cnt %= mod - 1
        now *= p
    ans *= pow(p, cnt, mod)
    ans %= mod
    
print(ans)
0