結果

問題 No.1259 スイッチ
ユーザー rlangevinrlangevin
提出日時 2023-10-12 00:07:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 91,812 KB
最終ジャッジ日時 2023-10-12 00:07:29
合計ジャッジ時間 11,254 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
91,308 KB
testcase_01 AC 101 ms
91,736 KB
testcase_02 AC 100 ms
91,480 KB
testcase_03 AC 105 ms
91,676 KB
testcase_04 AC 100 ms
91,608 KB
testcase_05 AC 103 ms
91,512 KB
testcase_06 AC 103 ms
91,504 KB
testcase_07 AC 100 ms
91,520 KB
testcase_08 AC 101 ms
91,388 KB
testcase_09 AC 102 ms
91,284 KB
testcase_10 AC 110 ms
91,504 KB
testcase_11 AC 115 ms
91,596 KB
testcase_12 AC 115 ms
91,448 KB
testcase_13 AC 111 ms
91,388 KB
testcase_14 AC 111 ms
91,700 KB
testcase_15 AC 105 ms
91,812 KB
testcase_16 AC 114 ms
91,392 KB
testcase_17 AC 109 ms
91,772 KB
testcase_18 AC 115 ms
91,392 KB
testcase_19 AC 111 ms
91,400 KB
testcase_20 AC 108 ms
91,784 KB
testcase_21 AC 114 ms
91,456 KB
testcase_22 AC 112 ms
91,540 KB
testcase_23 AC 113 ms
91,372 KB
testcase_24 AC 111 ms
91,768 KB
testcase_25 AC 111 ms
91,368 KB
testcase_26 AC 116 ms
91,620 KB
testcase_27 AC 112 ms
91,620 KB
testcase_28 AC 111 ms
91,520 KB
testcase_29 AC 112 ms
91,524 KB
testcase_30 AC 107 ms
91,696 KB
testcase_31 AC 114 ms
91,748 KB
testcase_32 AC 109 ms
91,800 KB
testcase_33 AC 114 ms
91,620 KB
testcase_34 AC 108 ms
91,468 KB
testcase_35 AC 112 ms
91,452 KB
testcase_36 AC 114 ms
91,568 KB
testcase_37 AC 115 ms
91,452 KB
testcase_38 AC 113 ms
91,380 KB
testcase_39 AC 117 ms
91,636 KB
testcase_40 AC 117 ms
91,688 KB
testcase_41 AC 113 ms
91,368 KB
testcase_42 AC 114 ms
91,604 KB
testcase_43 AC 106 ms
91,560 KB
testcase_44 AC 114 ms
91,768 KB
testcase_45 AC 115 ms
91,780 KB
testcase_46 AC 110 ms
91,668 KB
testcase_47 AC 112 ms
91,604 KB
testcase_48 AC 107 ms
91,752 KB
testcase_49 AC 112 ms
91,452 KB
testcase_50 AC 113 ms
91,448 KB
testcase_51 AC 105 ms
91,540 KB
testcase_52 AC 115 ms
91,612 KB
testcase_53 AC 107 ms
91,464 KB
testcase_54 AC 114 ms
91,508 KB
testcase_55 AC 104 ms
91,448 KB
testcase_56 AC 106 ms
91,500 KB
testcase_57 AC 113 ms
91,452 KB
testcase_58 AC 109 ms
91,620 KB
testcase_59 AC 113 ms
91,388 KB
testcase_60 AC 117 ms
91,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K, M = map(int, input().split())
mod = 10 ** 9 + 7
n = 10 ** 6 + 5
fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod


now = 0
for i in range(1, N + 1):
    if K % i == 0:
        now += fact[N - 1] * invfact[N - i] * pow(N, N - i, mod)
        now %= mod
        
if M == 1:
    print(now)
    exit()
    
ans = (pow(N, N, mod) - now) * pow(N - 1, mod - 2, mod)
print(ans % mod)
0