結果

問題 No.644 G L C C D M
ユーザー koba-e964koba-e964
提出日時 2021-09-27 11:47:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 78,016 KB
最終ジャッジ日時 2023-09-20 11:43:23
合計ジャッジ時間 3,955 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,108 KB
testcase_01 AC 69 ms
71,408 KB
testcase_02 AC 70 ms
71,308 KB
testcase_03 AC 72 ms
71,084 KB
testcase_04 AC 71 ms
71,084 KB
testcase_05 AC 73 ms
71,200 KB
testcase_06 AC 72 ms
71,412 KB
testcase_07 AC 72 ms
71,260 KB
testcase_08 AC 75 ms
71,196 KB
testcase_09 AC 71 ms
71,044 KB
testcase_10 AC 74 ms
75,428 KB
testcase_11 AC 76 ms
75,916 KB
testcase_12 AC 77 ms
75,848 KB
testcase_13 AC 92 ms
76,152 KB
testcase_14 AC 76 ms
75,420 KB
testcase_15 AC 72 ms
75,444 KB
testcase_16 AC 73 ms
75,548 KB
testcase_17 AC 72 ms
75,804 KB
testcase_18 AC 78 ms
75,536 KB
testcase_19 AC 71 ms
71,260 KB
testcase_20 AC 73 ms
75,512 KB
testcase_21 AC 72 ms
75,512 KB
testcase_22 AC 96 ms
78,016 KB
testcase_23 AC 89 ms
77,328 KB
testcase_24 AC 91 ms
76,664 KB
testcase_25 AC 76 ms
75,732 KB
testcase_26 AC 73 ms
75,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

n, m = map(int, input().split())
q = n // m
mod = pow(10, 9) + 7

moe = [1] * (q + 1)
fac = [1] * (q + 1)
for i in range(2, q + 1):
    if fac[i] != 1:
        continue
    fac[i] = i
    moe[i] = -1
    for j in range(2 * i, q + 1, i):
        fac[j] = i
        moe[j] = -moe[j] if j // i % i != 0 else 0

ans = 0
for i in range(1, q + 1):
    ans += (q // i) * (q // i - 1) * moe[i]

ans %= mod
for i in range(1, n - 1):
    ans = ans * i % mod

print(ans)
0