結果

問題 No.391 CODING WAR
ユーザー pluto77pluto77
提出日時 2016-10-23 08:50:14
言語 Python2
(2.7.18)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 6,600 KB
実行使用メモリ 15,268 KB
最終ジャッジ日時 2023-08-15 17:55:09
合計ジャッジ時間 5,518 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
15,144 KB
testcase_01 AC 107 ms
15,148 KB
testcase_02 AC 106 ms
15,260 KB
testcase_03 AC 108 ms
15,248 KB
testcase_04 AC 107 ms
15,104 KB
testcase_05 AC 107 ms
15,268 KB
testcase_06 AC 106 ms
15,164 KB
testcase_07 AC 107 ms
15,196 KB
testcase_08 AC 107 ms
15,268 KB
testcase_09 AC 323 ms
15,264 KB
testcase_10 AC 314 ms
15,228 KB
testcase_11 AC 243 ms
15,100 KB
testcase_12 AC 105 ms
15,200 KB
testcase_13 AC 295 ms
15,184 KB
testcase_14 AC 265 ms
15,100 KB
testcase_15 AC 288 ms
15,260 KB
testcase_16 AC 214 ms
15,184 KB
testcase_17 AC 237 ms
15,104 KB
testcase_18 AC 193 ms
15,232 KB
testcase_19 AC 195 ms
15,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_391

mod=10**9+7
n=10**5
fact=[0 for i in xrange(n+1)]
inv=[0 for i in xrange(n+1)]
factr=[0 for i in xrange(n+1)]
inv[1]=fact[0]=factr[0]=1
for i in xrange(2,n+1):
 inv[i]=inv[mod%i]*(mod-mod/i)%mod
for i in xrange(1,n+1):
 fact[i]=fact[i-1]*i%mod
 factr[i]=factr[i-1]*inv[i]%mod

def comb(n,k):
 if k<0 or k>n: return 0
 return factr[k]*fact[n]%mod*factr[n-k]%mod
def perm(n,k):
 if k<0 or k>n: return 0
 return fact[n]*factr[n-k]%mod
def hcomb(n,k):
 if n==0 and k==0: return 1
 return comb(n+k-1,k)
 
n,m=map(int,raw_input().split())
res=0
for i in xrange(1,m+1):
 a=pow(i,n,mod)*comb(m,i)%mod
 if (m-i)%2==0:
  res+=a
 else:
  res-=a
print (res%mod+mod)%mod
0