結果
| 問題 | 
                            No.391 CODING WAR
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-02-26 16:03:07 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 241 ms / 2,000 ms | 
| コード長 | 280 bytes | 
| コンパイル時間 | 289 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 75,956 KB | 
| 最終ジャッジ日時 | 2024-09-14 06:32:35 | 
| 合計ジャッジ時間 | 3,343 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
ソースコード
n, m = map(int, input().split())
mod = 10**9 + 7
if n < m:
    print(0)
    exit()
ans = 0
comb = 1
for i in range(m):
    ans += (-1)**i * comb * pow(m - i, n, mod)
    ans %= mod
    comb *= m - i
    comb %= mod
    comb *= pow(i + 1, mod - 2, mod)
    comb % mod
print(ans)