結果

問題 No.575 n! / m / m / m...
ユーザー shotoyooshotoyoo
提出日時 2021-06-19 18:41:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,242 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 76,708 KB
最終ジャッジ日時 2023-09-05 01:08:01
合計ジャッジ時間 5,591 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,992 KB
testcase_01 AC 77 ms
76,152 KB
testcase_02 AC 69 ms
71,684 KB
testcase_03 AC 70 ms
71,728 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 68 ms
71,832 KB
testcase_07 AC 70 ms
72,056 KB
testcase_08 AC 70 ms
71,984 KB
testcase_09 AC 71 ms
71,920 KB
testcase_10 AC 70 ms
72,036 KB
testcase_11 AC 69 ms
72,032 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 85 ms
76,180 KB
testcase_24 WA -
testcase_25 AC 86 ms
76,008 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で割れる回数
    """
    ans = 0
    kk = k
    while kk<=v:
        ans += v//kk
        kk *= 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