結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:28:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 603 bytes |
| 記録 | |
| コンパイル時間 | 259 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 87,424 KB |
| 最終ジャッジ日時 | 2025-03-31 17:29:56 |
| 合計ジャッジ時間 | 6,587 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 19 |
ソースコード
MOD = 10**12
n = int(input())
count2 = 0
count5 = 0
product = 1
for i in range(1, n + 1):
temp = i
# Count factors of 2
cnt2 = 0
while temp % 2 == 0:
cnt2 += 1
temp //= 2
count2 += cnt2
# Count factors of 5
cnt5 = 0
while temp % 5 == 0:
cnt5 += 1
temp //= 5
count5 += cnt5
# Multiply the remaining part to the product
product = (product * temp) % MOD
# Calculate powers of 2 and 5 modulo MOD
pow2 = pow(2, count2, MOD)
pow5 = pow(5, count5, MOD)
result = (product * pow2) % MOD
result = (result * pow5) % MOD
print(result)
lam6er