結果

問題 No.1259 スイッチ
ユーザー AEnAEn
提出日時 2023-07-23 17:30:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 738 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 81,668 KB
実行使用メモリ 75,580 KB
最終ジャッジ日時 2023-10-25 00:01:45
合計ジャッジ時間 29,424 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,516 KB
testcase_01 AC 38 ms
53,516 KB
testcase_02 AC 38 ms
53,516 KB
testcase_03 AC 38 ms
53,516 KB
testcase_04 AC 38 ms
53,516 KB
testcase_05 AC 38 ms
53,516 KB
testcase_06 AC 37 ms
53,516 KB
testcase_07 AC 37 ms
53,516 KB
testcase_08 AC 36 ms
53,516 KB
testcase_09 AC 37 ms
53,516 KB
testcase_10 AC 458 ms
69,324 KB
testcase_11 AC 689 ms
74,548 KB
testcase_12 AC 438 ms
68,844 KB
testcase_13 AC 278 ms
65,212 KB
testcase_14 AC 376 ms
67,452 KB
testcase_15 AC 268 ms
65,020 KB
testcase_16 AC 576 ms
72,004 KB
testcase_17 AC 360 ms
67,156 KB
testcase_18 AC 651 ms
73,644 KB
testcase_19 AC 644 ms
73,572 KB
testcase_20 AC 466 ms
69,460 KB
testcase_21 AC 702 ms
74,932 KB
testcase_22 AC 244 ms
64,452 KB
testcase_23 AC 635 ms
73,316 KB
testcase_24 AC 486 ms
70,028 KB
testcase_25 AC 479 ms
69,748 KB
testcase_26 AC 714 ms
75,156 KB
testcase_27 AC 590 ms
72,300 KB
testcase_28 AC 482 ms
69,788 KB
testcase_29 AC 590 ms
72,260 KB
testcase_30 AC 381 ms
67,540 KB
testcase_31 AC 534 ms
71,020 KB
testcase_32 AC 251 ms
64,620 KB
testcase_33 AC 718 ms
75,244 KB
testcase_34 AC 409 ms
68,172 KB
testcase_35 AC 557 ms
71,652 KB
testcase_36 AC 519 ms
70,684 KB
testcase_37 AC 492 ms
70,028 KB
testcase_38 AC 455 ms
69,220 KB
testcase_39 AC 685 ms
74,452 KB
testcase_40 AC 695 ms
74,660 KB
testcase_41 AC 581 ms
72,052 KB
testcase_42 AC 707 ms
74,948 KB
testcase_43 AC 434 ms
68,748 KB
testcase_44 AC 667 ms
74,212 KB
testcase_45 AC 732 ms
75,548 KB
testcase_46 AC 421 ms
68,356 KB
testcase_47 AC 729 ms
75,396 KB
testcase_48 AC 370 ms
67,292 KB
testcase_49 AC 708 ms
74,924 KB
testcase_50 AC 417 ms
68,332 KB
testcase_51 AC 248 ms
64,516 KB
testcase_52 AC 687 ms
74,548 KB
testcase_53 AC 328 ms
66,380 KB
testcase_54 AC 686 ms
74,420 KB
testcase_55 AC 238 ms
64,252 KB
testcase_56 AC 365 ms
67,236 KB
testcase_57 AC 638 ms
73,316 KB
testcase_58 AC 448 ms
69,076 KB
testcase_59 AC 544 ms
71,196 KB
testcase_60 AC 738 ms
75,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K,M = map(int, input().split())

mod = 10**9+7
fac = [1]*(N+1)
inv = [1]*(N+1)
for i in range(1,N+1):
    fac[i] = (fac[i-1]*i)%mod
    inv[i] = (inv[i-1]*pow(i,mod-2,mod))%mod

def npr(n,r):
    return fac[n]*inv[n-r]%mod

res = 0
for d in range(1,N+1):
    if K%d==0:
        res += (npr(N-1,d-1)*pow(N,N-d,mod))%mod
        res %= mod

if M==1:
    print(res)
else:
    inv = pow(N-1,mod-2,mod)
    res2 = (pow(N,N,mod)-res)*inv%mod
    print(res2)
0