結果

問題 No.1035 Color Box
ユーザー googol_S0googol_S0
提出日時 2020-04-24 21:39:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 82,896 KB
実行使用メモリ 122,096 KB
最終ジャッジ日時 2024-04-23 03:02:46
合計ジャッジ時間 5,509 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
120,524 KB
testcase_01 AC 79 ms
104,728 KB
testcase_02 AC 80 ms
104,316 KB
testcase_03 AC 99 ms
112,068 KB
testcase_04 AC 93 ms
111,484 KB
testcase_05 AC 88 ms
109,424 KB
testcase_06 AC 78 ms
105,432 KB
testcase_07 AC 84 ms
105,708 KB
testcase_08 AC 139 ms
119,920 KB
testcase_09 AC 113 ms
119,292 KB
testcase_10 AC 76 ms
104,980 KB
testcase_11 AC 82 ms
104,096 KB
testcase_12 AC 83 ms
104,448 KB
testcase_13 AC 126 ms
120,204 KB
testcase_14 AC 134 ms
122,096 KB
testcase_15 AC 136 ms
121,372 KB
testcase_16 AC 78 ms
104,976 KB
testcase_17 AC 76 ms
104,320 KB
testcase_18 AC 77 ms
104,056 KB
testcase_19 AC 143 ms
120,496 KB
testcase_20 AC 77 ms
103,892 KB
testcase_21 AC 78 ms
104,200 KB
testcase_22 AC 77 ms
104,856 KB
testcase_23 AC 77 ms
105,180 KB
testcase_24 AC 81 ms
104,328 KB
testcase_25 AC 78 ms
104,328 KB
testcase_26 AC 76 ms
104,836 KB
testcase_27 AC 77 ms
104,256 KB
testcase_28 AC 76 ms
104,028 KB
testcase_29 AC 77 ms
105,716 KB
testcase_30 AC 76 ms
104,228 KB
testcase_31 AC 77 ms
104,228 KB
testcase_32 AC 79 ms
104,396 KB
testcase_33 AC 76 ms
103,844 KB
testcase_34 AC 76 ms
103,960 KB
testcase_35 AC 77 ms
104,932 KB
testcase_36 AC 76 ms
103,788 KB
testcase_37 AC 76 ms
103,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def cmb(n, r):
    global mod
    if ( r<0 or r>n ):
        return 1
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
def f(n,r):
  return cmb(n+r-1,r)
 
mod = 10**9+7 #出力の制限
N = 100000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, N*2 + 3 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,M=map(int,input().split())
P=0
X=1
for i in range(M):
  P+=X*(pow(M-i,N,mod)*cmb(M,M-i))
  X*=-1
print(P%mod)
0