結果

問題 No.1035 Color Box
ユーザー GeckoちゃんGeckoちゃん
提出日時 2020-05-20 10:54:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,099 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 33,536 KB
最終ジャッジ日時 2024-04-09 22:53:27
合計ジャッジ時間 9,579 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,099 ms
33,536 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 106 ms
12,416 KB
testcase_04 AC 109 ms
12,544 KB
testcase_05 AC 55 ms
11,392 KB
testcase_06 AC 32 ms
10,880 KB
testcase_07 AC 37 ms
10,880 KB
testcase_08 AC 922 ms
30,592 KB
testcase_09 AC 381 ms
18,816 KB
testcase_10 AC 28 ms
10,880 KB
testcase_11 AC 27 ms
10,752 KB
testcase_12 AC 26 ms
10,752 KB
testcase_13 AC 724 ms
26,240 KB
testcase_14 AC 823 ms
28,160 KB
testcase_15 AC 1,020 ms
33,408 KB
testcase_16 AC 25 ms
10,752 KB
testcase_17 AC 26 ms
10,752 KB
testcase_18 AC 26 ms
10,752 KB
testcase_19 AC 1,008 ms
33,536 KB
testcase_20 AC 26 ms
10,752 KB
testcase_21 AC 28 ms
10,752 KB
testcase_22 AC 27 ms
10,752 KB
testcase_23 AC 26 ms
10,880 KB
testcase_24 AC 27 ms
10,880 KB
testcase_25 AC 26 ms
10,752 KB
testcase_26 AC 26 ms
10,752 KB
testcase_27 AC 25 ms
10,752 KB
testcase_28 AC 25 ms
10,752 KB
testcase_29 AC 26 ms
10,752 KB
testcase_30 AC 26 ms
10,752 KB
testcase_31 AC 25 ms
10,752 KB
testcase_32 AC 25 ms
10,752 KB
testcase_33 AC 27 ms
10,880 KB
testcase_34 AC 28 ms
10,880 KB
testcase_35 AC 27 ms
10,752 KB
testcase_36 AC 27 ms
10,752 KB
testcase_37 AC 25 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit
setrecursionlimit(1000000)


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