結果

問題 No.391 CODING WAR
ユーザー fumofumofunifumofumofuni
提出日時 2021-09-13 19:14:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 249 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 80,652 KB
最終ジャッジ日時 2023-09-08 02:45:39
合計ジャッジ時間 5,870 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
77,540 KB
testcase_01 AC 149 ms
77,896 KB
testcase_02 AC 148 ms
77,812 KB
testcase_03 AC 147 ms
77,980 KB
testcase_04 AC 147 ms
77,780 KB
testcase_05 AC 147 ms
77,876 KB
testcase_06 AC 147 ms
77,748 KB
testcase_07 AC 146 ms
77,780 KB
testcase_08 AC 146 ms
77,772 KB
testcase_09 AC 249 ms
80,576 KB
testcase_10 AC 227 ms
80,652 KB
testcase_11 AC 207 ms
80,492 KB
testcase_12 AC 145 ms
77,832 KB
testcase_13 AC 239 ms
80,480 KB
testcase_14 AC 231 ms
79,956 KB
testcase_15 AC 242 ms
80,012 KB
testcase_16 AC 209 ms
79,668 KB
testcase_17 AC 214 ms
79,684 KB
testcase_18 AC 198 ms
78,928 KB
testcase_19 AC 198 ms
78,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=1000000007
maxM=100010
fact=[0]*maxM
fact[0]=1
for i in range(1,maxM):
    fact[i]=fact[i-1]*i%mod
ifact=[0]*maxM
for i in range(maxM):
    ifact[i]=pow(fact[i],mod-2,mod)
def comb(n,k):
    if k<0 or k>n:
        return 0
    return fact[n]*ifact[k]*ifact[n-k]%mod
N,M=map(int,input().split())
ans=0
for i in range(M):
    if i%2==0:
        ans=(ans+comb(M,i)*pow(M-i,N,mod))%mod
    else :
        ans=(ans-comb(M,i)*pow(M-i,N,mod))%mod
        ans=(ans+mod)%mod
print(ans)
0