結果
| 問題 |
No.500 階乗電卓
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:21:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 677 bytes |
| コンパイル時間 | 281 ms |
| コンパイル使用メモリ | 82,688 KB |
| 実行使用メモリ | 52,480 KB |
| 最終ジャッジ日時 | 2025-06-12 16:22:19 |
| 合計ジャッジ時間 | 2,089 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 13 |
ソースコード
def count_factors(n, factor):
count = 0
while n > 0:
n = n // factor
count += n
return count
N = int(input())
cnt2 = count_factors(N, 2)
cnt5 = count_factors(N, 5)
t = min(cnt2, cnt5)
if t >= 12:
print(0)
else:
mod = 10 ** 12
product = 1
for i in range(1, N + 1):
x = i
while x % 2 == 0:
x = x // 2
while x % 5 == 0:
x = x // 5
product = (product * x) % mod
excess_2 = cnt2 - t
excess_5 = cnt5 - t
product = (product * pow(2, excess_2, mod)) % mod
product = (product * pow(5, excess_5, mod)) % mod
product = (product * (10 ** t)) % mod
print(product)
gew1fw