結果

問題 No.575 n! / m / m / m...
ユーザー shotoyooshotoyoo
提出日時 2021-06-19 18:50:32
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,484 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,360 KB
実行使用メモリ 80,708 KB
最終ジャッジ日時 2023-09-05 01:08:26
合計ジャッジ時間 5,645 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 73 ms
71,868 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 72 ms
71,628 KB
testcase_07 AC 72 ms
71,652 KB
testcase_08 AC 72 ms
71,660 KB
testcase_09 AC 75 ms
71,620 KB
testcase_10 AC 73 ms
71,960 KB
testcase_11 AC 74 ms
71,836 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

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(n,m):
    """n!がmで割れる回数
    """
    f = factor(m)
    ans = float("inf")
    for k in f:
        kk = k
        val = 0
        while kk<=n:
            val += v//kk
            kk *= k
        ans = min(ans, val//f[k])
    return ans
def dn(v,k):
    """vがkで割れる回数
    """
    ans = 0
    while v%k==0:
        ans += 1
        v //= k
    return ans

f2 = factor(m)
val = divnum(n,m)
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