結果

問題 No.2798 Multiple Chain
ユーザー mkawa2mkawa2
提出日時 2024-06-28 23:16:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 3,128 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 66,304 KB
最終ジャッジ日時 2024-06-28 23:16:34
合計ジャッジ時間 3,704 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
61,312 KB
testcase_01 AC 44 ms
61,184 KB
testcase_02 AC 41 ms
61,568 KB
testcase_03 AC 43 ms
61,312 KB
testcase_04 AC 43 ms
61,284 KB
testcase_05 AC 42 ms
61,696 KB
testcase_06 AC 42 ms
61,824 KB
testcase_07 AC 44 ms
60,928 KB
testcase_08 AC 44 ms
61,440 KB
testcase_09 AC 44 ms
60,928 KB
testcase_10 AC 43 ms
61,056 KB
testcase_11 AC 48 ms
61,184 KB
testcase_12 AC 43 ms
61,056 KB
testcase_13 AC 44 ms
61,312 KB
testcase_14 AC 44 ms
61,696 KB
testcase_15 AC 46 ms
61,824 KB
testcase_16 AC 45 ms
61,696 KB
testcase_17 AC 44 ms
61,568 KB
testcase_18 AC 44 ms
61,824 KB
testcase_19 AC 42 ms
61,824 KB
testcase_20 AC 41 ms
60,928 KB
testcase_21 AC 41 ms
61,056 KB
testcase_22 AC 44 ms
61,440 KB
testcase_23 AC 46 ms
61,184 KB
testcase_24 AC 54 ms
61,312 KB
testcase_25 AC 42 ms
61,440 KB
testcase_26 AC 43 ms
61,568 KB
testcase_27 AC 42 ms
61,952 KB
testcase_28 AC 45 ms
61,696 KB
testcase_29 AC 42 ms
61,312 KB
testcase_30 AC 43 ms
61,696 KB
testcase_31 AC 46 ms
61,568 KB
testcase_32 AC 54 ms
66,304 KB
testcase_33 AC 47 ms
63,744 KB
testcase_34 AC 51 ms
66,304 KB
testcase_35 AC 43 ms
61,696 KB
testcase_36 AC 43 ms
62,464 KB
testcase_37 AC 41 ms
61,440 KB
testcase_38 AC 42 ms
61,696 KB
testcase_39 AC 43 ms
61,824 KB
testcase_40 AC 42 ms
61,696 KB
testcase_41 AC 42 ms
61,440 KB
testcase_42 AC 42 ms
61,312 KB
testcase_43 AC 43 ms
61,312 KB
testcase_44 AC 44 ms
61,440 KB
testcase_45 AC 55 ms
61,568 KB
testcase_46 AC 42 ms
61,184 KB
testcase_47 AC 42 ms
61,440 KB
testcase_48 AC 42 ms
61,440 KB
testcase_49 AC 41 ms
61,184 KB
testcase_50 AC 40 ms
61,440 KB
testcase_51 AC 41 ms
61,312 KB
testcase_52 AC 44 ms
63,976 KB
testcase_53 AC 43 ms
61,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

n=70
dp=[[0]*n for _ in range(n)]
dp[1][1]=1
for i in range(n):
    for j in range(n):
        pre=dp[i][j]
        if pre==0:continue
        if i+1<n and j+1<n:
            dp[i+1][j+1]+=pre
        if j+i<n:
            dp[i][j+i]+=pre
cs=[[0]*(n+5) for _ in range(n+5)]
for j in range(n):
    for i in range(n):
        cs[i][j]=cs[i-1][j]+dp[i][j]

def gcd(a, b):
    while a:
        a, b = b%a, a
    return b

def is_prime(n):
    if n == 2:
        return 1
    if n == 1 or n%2 == 0:
        return 0

    m = n - 1
    lsb = m & -m
    s = lsb.bit_length()-1
    d = m // lsb

    test_numbers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]

    for a in test_numbers:
        if a == n:
            continue
        x = pow(a,d,n)
        r = 0
        if x == 1:
            continue
        while x != m:
            x = pow(x,2,n)
            r += 1
            if x == 1 or r == s:
                return 0
    return 1


def find_prime_factor(n):
    if n%2 == 0:
        return 2

    m = int(n**0.125)+1

    for c in range(1,n):
        f = lambda a: (pow(a,2,n)+c)%n
        y = 0
        g = q = r = 1
        k = 0
        while g == 1:
            x = y
            while k < 3*r//4:
                y = f(y)
                k += 1
            while k < r and g == 1:
                ys = y
                for _ in range(min(m, r-k)):
                    y = f(y)
                    q = q*abs(x-y)%n
                g = gcd(q,n)
                k += m
            k = r
            r *= 2
        if g == n:
            g = 1
            y = ys
            while g == 1:
                y = f(y)
                g = gcd(abs(x-y),n)
        if g == n:
            continue
        if is_prime(g):
            return g
        elif is_prime(n//g):
            return n//g
        else:
            return find_prime_factor(g)


def factorize(n):
    res = {}
    while not is_prime(n) and n > 1:  # nが合成数である間nの素因数の探索を繰り返す
        p = find_prime_factor(n)
        s = 0
        while n%p == 0:  # nが素因数pで割れる間割り続け、出力に追加
            n //= p
            s += 1
        res[p] = s
    if n > 1:  # n>1であればnは素数なので出力に追加
        res[n] = 1
    return res

n=II()
pe=factorize(n)
ans=1
for e in pe.values():
    ans*=cs[61][e]
print(ans)
0