結果
問題 |
No.391 CODING WAR
|
ユーザー |
![]() |
提出日時 | 2020-03-05 12:43:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 620 ms / 2,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 18,560 KB |
最終ジャッジ日時 | 2024-10-14 00:57:56 |
合計ジャッジ時間 | 5,890 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 10**9 + 7 # %% N, M = map(int, read().split()) # %% fact = [1] * (M + 1) for n in range(1, M + 1): fact[n] = fact[n - 1] * n % MOD fact_inv = [1] * (M + 1) fact_inv[M] = pow(fact[M], MOD - 2, MOD) for n in range(M, 0, -1): fact_inv[n - 1] = fact_inv[n] * n % MOD # %% x = 0 for i in range(M): comb = fact[M] * fact_inv[i] * fact_inv[M - i] % MOD p = pow(M - i, N, MOD) x += (-1) ** i * comb * p print(x % MOD)