結果

問題 No.1035 Color Box
ユーザー takakintakakin
提出日時 2020-06-08 21:56:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 501 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 23,996 KB
最終ジャッジ日時 2023-08-27 04:39:29
合計ジャッジ時間 9,853 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 385 ms
23,944 KB
testcase_01 AC 150 ms
23,948 KB
testcase_02 AC 162 ms
23,892 KB
testcase_03 AC 187 ms
23,912 KB
testcase_04 AC 176 ms
23,872 KB
testcase_05 AC 162 ms
23,792 KB
testcase_06 AC 154 ms
23,828 KB
testcase_07 AC 155 ms
23,828 KB
testcase_08 AC 363 ms
23,768 KB
testcase_09 AC 241 ms
23,932 KB
testcase_10 AC 153 ms
23,892 KB
testcase_11 AC 152 ms
23,952 KB
testcase_12 AC 154 ms
23,956 KB
testcase_13 AC 326 ms
23,940 KB
testcase_14 AC 343 ms
23,828 KB
testcase_15 AC 393 ms
23,948 KB
testcase_16 AC 154 ms
23,904 KB
testcase_17 AC 163 ms
23,912 KB
testcase_18 AC 154 ms
23,768 KB
testcase_19 AC 392 ms
23,768 KB
testcase_20 AC 158 ms
23,772 KB
testcase_21 AC 154 ms
23,800 KB
testcase_22 AC 152 ms
23,996 KB
testcase_23 AC 157 ms
23,764 KB
testcase_24 AC 155 ms
23,836 KB
testcase_25 AC 161 ms
23,888 KB
testcase_26 AC 153 ms
23,820 KB
testcase_27 AC 154 ms
23,872 KB
testcase_28 AC 153 ms
23,768 KB
testcase_29 AC 152 ms
23,768 KB
testcase_30 AC 150 ms
23,932 KB
testcase_31 AC 156 ms
23,836 KB
testcase_32 AC 156 ms
23,828 KB
testcase_33 AC 158 ms
23,948 KB
testcase_34 AC 157 ms
23,948 KB
testcase_35 AC 155 ms
23,944 KB
testcase_36 AC 157 ms
23,876 KB
testcase_37 AC 156 ms
23,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
mod=10**9+7
n_max=2*(10**5+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod

ans=0
for i in range(m):
  if i%2:
    ans=(ans-pow(m-i,n,mod)*comb(m,i))%mod
  else:
    ans=(ans+pow(m-i,n,mod)*comb(m,i))%mod
print(ans)
0