結果

問題 No.644 G L C C D M
ユーザー shotoyooshotoyoo
提出日時 2021-06-18 00:48:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 77,456 KB
最終ジャッジ日時 2023-09-02 12:20:09
合計ジャッジ時間 4,526 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,320 KB
testcase_01 AC 69 ms
71,200 KB
testcase_02 AC 70 ms
71,276 KB
testcase_03 AC 75 ms
71,252 KB
testcase_04 AC 71 ms
71,408 KB
testcase_05 AC 70 ms
71,260 KB
testcase_06 AC 70 ms
71,196 KB
testcase_07 AC 71 ms
71,492 KB
testcase_08 AC 74 ms
75,868 KB
testcase_09 AC 75 ms
75,844 KB
testcase_10 AC 78 ms
76,004 KB
testcase_11 AC 81 ms
76,640 KB
testcase_12 AC 82 ms
76,172 KB
testcase_13 AC 84 ms
76,720 KB
testcase_14 AC 86 ms
76,636 KB
testcase_15 AC 83 ms
76,588 KB
testcase_16 AC 84 ms
76,684 KB
testcase_17 AC 72 ms
71,332 KB
testcase_18 AC 72 ms
72,284 KB
testcase_19 AC 72 ms
71,268 KB
testcase_20 AC 73 ms
71,452 KB
testcase_21 AC 84 ms
76,708 KB
testcase_22 AC 99 ms
77,240 KB
testcase_23 AC 97 ms
77,236 KB
testcase_24 AC 98 ms
77,180 KB
testcase_25 AC 98 ms
77,344 KB
testcase_26 AC 97 ms
77,456 KB
権限があれば一括ダウンロードができます

ソースコード

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