結果

問題 No.1263 ご注文は数学ですか?
ユーザー gew1fw
提出日時 2025-06-12 16:11:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 353 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 83,012 KB
実行使用メモリ 53,960 KB
最終ジャッジ日時 2025-06-12 16:11:37
合計ジャッジ時間 1,064 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

x = int(input())
mod = 10**9 + 7

# Precompute factorial mod mod
fact = 1
for i in range(2, x + 1):
    fact = (fact * i) % mod

# The result is (-1) * (x! // 2)
# Since we are working modulo mod, division by 2 is multiplication by the modular inverse of 2
inv2 = pow(2, mod - 2, mod)
result = (-fact) % mod
result = (result * inv2) % mod

print(result)
0