結果

問題 No.575 n! / m / m / m...
ユーザー shotoyooshotoyoo
提出日時 2021-06-19 18:46:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 1,353 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 87,384 KB
実行使用メモリ 76,812 KB
最終ジャッジ日時 2023-09-05 01:08:12
合計ジャッジ時間 3,976 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,772 KB
testcase_01 AC 77 ms
75,844 KB
testcase_02 AC 71 ms
71,924 KB
testcase_03 AC 72 ms
72,112 KB
testcase_04 AC 72 ms
71,904 KB
testcase_05 AC 72 ms
71,664 KB
testcase_06 AC 73 ms
71,952 KB
testcase_07 AC 72 ms
71,916 KB
testcase_08 AC 73 ms
71,884 KB
testcase_09 AC 73 ms
71,636 KB
testcase_10 AC 73 ms
72,052 KB
testcase_11 AC 73 ms
71,920 KB
testcase_12 AC 80 ms
76,660 KB
testcase_13 AC 81 ms
76,680 KB
testcase_14 AC 80 ms
76,812 KB
testcase_15 AC 78 ms
76,688 KB
testcase_16 AC 81 ms
76,676 KB
testcase_17 AC 74 ms
76,140 KB
testcase_18 AC 75 ms
75,992 KB
testcase_19 AC 75 ms
76,136 KB
testcase_20 AC 76 ms
75,888 KB
testcase_21 AC 76 ms
76,140 KB
testcase_22 AC 73 ms
71,692 KB
testcase_23 AC 90 ms
76,132 KB
testcase_24 AC 74 ms
72,128 KB
testcase_25 AC 89 ms
76,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = 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 math
def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    f = {}
    tmp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M+1):
        if tmp<i:
            break
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp //= i
            f[i] = cnt
    if tmp!=1:
        f[tmp] = 1
    if not f:
        f[n] = 1
    return f
def divnum(v,k):
    """v!がkで割れる回数
    """
    assert v>=k
    ans = 0
    kk = k
    while kk<=v:
        ans += v//kk
        kk *= k
    return ans
f2 = factor(m)
val = float("inf")
for k in f2:
    if k>n:
        val = 0
        break
    val = 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) - n
    ans /= math.log(10)
ans -= val * math.log10(m)
v = math.pow(10, ans%1)
# print(v)
e = ans//1
print(f"{v}e{int(e)}")
# print("{:e}".format(p))
0