結果
問題 | No.575 n! / m / m / m... |
ユーザー |
![]() |
提出日時 | 2020-03-24 22:02:41 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 995 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 119,932 KB |
最終ジャッジ日時 | 2025-01-01 18:26:22 |
合計ジャッジ時間 | 34,892 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 TLE * 1 |
other | AC * 23 |
ソースコード
#!/usr/bin/ python3.8import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinesimport numpy as npfrom scipy.special import loggammaN, M = map(int, read().split())U = 10 ** 6 + 10is_prime = np.zeros(U, np.bool)is_prime[2] = 1is_prime[3::2] = 1for p in range(3, U, 2):if p * p > U:breakif is_prime[p]:is_prime[p * p::p + p] = 0primes = np.where(is_prime)[0]def factor(N):div = primes[N % primes == 0].tolist()for p in div:e = 0while N % p == 0:N //= pe += 1yield (p, e)if N > 1:yield (N, 1)def fact_ord(p, N):ret = 0while N:N //= pret += Nreturn retT = N + 10for p, e in factor(M):f = fact_ord(p, N)if T > f // e:T = f // elog_x = (loggamma(N + 1) - T * np.log(M))d = int(log_x // np.log(10))log_x -= np.log(10) * dx = np.exp(log_x)print(f'{x:.3f}e{d}')