結果
問題 | No.575 n! / m / m / m... |
ユーザー |
|
提出日時 | 2021-06-19 18:46:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 1,353 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 60,160 KB |
最終ジャッジ日時 | 2024-06-22 22:16:02 |
合計ジャッジ時間 | 2,544 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
import sysinput = lambda : sys.stdin.readline().rstrip()sys.setrecursionlimit(2*10**5+10)write = lambda x: sys.stdout.write(x+"\n")debug = lambda x: sys.stderr.write(x+"\n")writef = lambda x: print("{:.12f}".format(x))n,m = list(map(int, input().split()))import mathdef factor(n, m=None):# mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力するf = {}tmp = nM = int(-(-n**0.5//1))+1if m is not None:M = min(m+1, M)for i in range(2, M+1):if tmp<i:breakif tmp%i==0:cnt=0while tmp%i==0:cnt+=1tmp //= if[i] = cntif tmp!=1:f[tmp] = 1if not f:f[n] = 1return fdef divnum(v,k):"""v!がkで割れる回数"""assert v>=kans = 0kk = kwhile kk<=v:ans += v//kkkk *= kreturn ansf2 = factor(m)val = float("inf")for k in f2:if k>n:val = 0breakval = min(val, divnum(n,k)//f2[k])if n<10**6:ans = sum((math.log10(i) for i in range(1, n+1)))else:ans = math.log(2*math.pi*n)/2 + n*math.log(n) - nans /= math.log(10)ans -= val * math.log10(m)v = math.pow(10, ans%1)# print(v)e = ans//1print(f"{v}e{int(e)}")# print("{:e}".format(p))