結果
| 問題 |
No.1044 正直者大学
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-05-01 22:32:38 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 660 ms / 2,000 ms |
| コード長 | 1,218 bytes |
| コンパイル時間 | 488 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 55,100 KB |
| 最終ジャッジ日時 | 2024-12-25 13:10:11 |
| 合計ジャッジ時間 | 21,035 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
ソースコード
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
def cumprod(A, MOD=MOD):
L = len(A)
Lsq = int(L**.5 + 1)
A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)
for n in range(1, Lsq):
A[:, n] *= A[:, n - 1]
A[:, n] %= MOD
for n in range(1, Lsq):
A[n] *= A[n - 1, -1]
A[n] %= MOD
return A.ravel()[:L]
def make_fact(U, MOD=MOD):
x = np.arange(U, dtype=np.int64)
x[0] = 1
fact = cumprod(x, MOD)
x = np.arange(U, 0, -1, dtype=np.int64)
x[0] = pow(int(fact[-1]), MOD - 2, MOD)
fact_inv = cumprod(x, MOD)[::-1]
fact.flags.writeable = False
fact_inv.flags.writeable = False
return fact, fact_inv
N, M, K = map(int, read().split())
fact, fact_inv = make_fact(2 * 10 ** 5 + 10)
inv = np.zeros_like(fact)
inv[1:] = fact_inv[1:] * fact[:-1] % MOD
U = min(N, M)
x = fact[N-1] * fact[M-1] % MOD * fact[N] % MOD * fact[M] % MOD
x = x * fact_inv[:U] % MOD * fact_inv[1:U+1] % MOD
x = x * fact_inv[N-U:N][::-1] % MOD * fact_inv[M-U:M][::-1] % MOD
i = np.arange(1, U+1)
cond = N + M - 2 * i >= K
answer = (x * cond).sum() % MOD
print(answer)
maspy