結果

問題 No.644 G L C C D M
ユーザー shotoyooshotoyoo
提出日時 2021-06-18 00:48:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 62,976 KB
最終ジャッジ日時 2024-06-11 19:02:29
合計ジャッジ時間 3,035 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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