結果

問題 No.1035 Color Box
ユーザー GeckoちゃんGeckoちゃん
提出日時 2020-05-20 10:52:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 371 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 15,232 KB
最終ジャッジ日時 2024-04-09 22:53:17
合計ジャッジ時間 2,656 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 35 ms
10,880 KB
testcase_07 AC 39 ms
11,008 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 28 ms
10,752 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 28 ms
10,880 KB
testcase_17 AC 28 ms
10,752 KB
testcase_18 AC 29 ms
10,752 KB
testcase_19 RE -
testcase_20 AC 30 ms
10,752 KB
testcase_21 AC 28 ms
10,880 KB
testcase_22 AC 28 ms
10,752 KB
testcase_23 AC 29 ms
10,752 KB
testcase_24 AC 28 ms
10,752 KB
testcase_25 AC 28 ms
10,752 KB
testcase_26 AC 28 ms
10,752 KB
testcase_27 AC 28 ms
10,752 KB
testcase_28 AC 27 ms
10,752 KB
testcase_29 AC 27 ms
10,752 KB
testcase_30 AC 28 ms
10,752 KB
testcase_31 AC 28 ms
10,752 KB
testcase_32 AC 28 ms
10,752 KB
testcase_33 AC 28 ms
10,752 KB
testcase_34 AC 28 ms
10,752 KB
testcase_35 AC 28 ms
10,752 KB
testcase_36 AC 28 ms
10,752 KB
testcase_37 AC 28 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

B = 10**9 + 7

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


fac = [0]*(M+1)
fac[0]=1
for i in range(M):
    fac[i+1]=fac[i]*(i+1)%B

def comb(n,k):
    if n==0 and k==0:
        return 1
    if n<k or k<0:
        return 0
    return fac[n]*pow(fac[n-k],10**9+5,B)*pow(fac[k],10**9+5,B)%B

def f(i):
    if i==0:
        return 0
    return (comb(M,i)*pow(i,N,B)-f(i-1))%B

print(f(M))
0