結果

問題 No.644 G L C C D M
コンテスト
ユーザー shotoyoo
提出日時 2021-06-18 00:48:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 358 ms
コンパイル使用メモリ 85,172 KB
実行使用メモリ 64,228 KB
最終ジャッジ日時 2026-03-05 00:57:00
合計ジャッジ時間 2,481 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,m = list(map(int, input().split()))
M = 10**9+7
vals = [0]*(n+1)
v = 0
v2 = 0
if m>n:
    ans = 0
else:
    for i in range(1,n+1)[::-1]:
        v = (n//i)*(n//i-1)%M
        for j in range(2*i,n+1,i):
            v -= vals[j]
            v %= M
        vals[i] = v
    ans = vals[m] % M
    for i in range(2, n-1):
        ans *= i
        ans %= M
print(ans%M)
0