結果

問題 No.2318 Phys Bone Maker
ユーザー FromBooskaFromBooska
提出日時 2023-05-27 13:50:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,779 ms / 3,000 ms
コード長 1,781 bytes
コンパイル時間 1,346 ms
コンパイル使用メモリ 86,508 KB
実行使用メモリ 80,796 KB
最終ジャッジ日時 2023-08-26 20:53:49
合計ジャッジ時間 20,932 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,560 KB
testcase_01 AC 73 ms
71,548 KB
testcase_02 AC 1,779 ms
80,616 KB
testcase_03 AC 101 ms
75,760 KB
testcase_04 AC 111 ms
76,048 KB
testcase_05 AC 96 ms
75,528 KB
testcase_06 AC 98 ms
75,620 KB
testcase_07 AC 91 ms
76,556 KB
testcase_08 AC 128 ms
76,428 KB
testcase_09 AC 103 ms
75,620 KB
testcase_10 AC 133 ms
75,720 KB
testcase_11 AC 149 ms
75,720 KB
testcase_12 AC 205 ms
76,364 KB
testcase_13 AC 198 ms
76,740 KB
testcase_14 AC 116 ms
75,596 KB
testcase_15 AC 115 ms
75,664 KB
testcase_16 AC 100 ms
76,116 KB
testcase_17 AC 127 ms
75,632 KB
testcase_18 AC 189 ms
76,520 KB
testcase_19 AC 92 ms
75,752 KB
testcase_20 AC 107 ms
75,568 KB
testcase_21 AC 97 ms
75,880 KB
testcase_22 AC 101 ms
75,692 KB
testcase_23 AC 98 ms
75,952 KB
testcase_24 AC 122 ms
75,832 KB
testcase_25 AC 129 ms
75,392 KB
testcase_26 AC 133 ms
76,424 KB
testcase_27 AC 112 ms
75,620 KB
testcase_28 AC 94 ms
75,596 KB
testcase_29 AC 89 ms
75,592 KB
testcase_30 AC 89 ms
75,388 KB
testcase_31 AC 147 ms
75,568 KB
testcase_32 AC 109 ms
75,752 KB
testcase_33 AC 72 ms
71,792 KB
testcase_34 AC 130 ms
75,628 KB
testcase_35 AC 360 ms
78,568 KB
testcase_36 AC 919 ms
80,448 KB
testcase_37 AC 877 ms
80,276 KB
testcase_38 AC 1,035 ms
79,976 KB
testcase_39 AC 1,376 ms
80,580 KB
testcase_40 AC 1,515 ms
80,796 KB
testcase_41 AC 1,494 ms
80,628 KB
testcase_42 AC 1,728 ms
80,620 KB
testcase_43 AC 207 ms
76,824 KB
testcase_44 AC 559 ms
78,780 KB
testcase_45 AC 538 ms
79,160 KB
testcase_46 AC 1,589 ms
80,608 KB
testcase_47 AC 110 ms
75,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# Nの約数にしか止まらないから約数頂点上でのdp
# しかしうまく実装できず人のを見る
# https://yukicoder.me/submissions/872922

N = int(input())

def divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def factorization_dic(n): #辞書形式に改造
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt
    if temp!=1:
        arr[temp] = 1
    if arr==[]:
        arr[n] = 1
    return arr

N_divs = divisors(N)
L = len(N_divs)

all_factors = []
for d in N_divs:
    all_factors.append(factorization_dic(d))

#print(all_factors)

mod = 998244353

# Nの約数を大きい方から1まで並べるのはうまくいかないので小さい方からやる
# dp[i]パターン数

dp = [0]*L
dp[0] = 1 

for i in range(L):
    for j in range(i+1, L):
        if N_divs[j]%N_divs[i] != 0:
            continue
        temp = dp[i]
        for p in all_factors[i]:
            if p == 1:
                continue
            p_count_current = all_factors[i][p] 
            p_count_new = all_factors[j][p]
            
            if p_count_current == p_count_new:
                # 公式解説に説明あるけどよくわかんないね
                #print('i', i, 'j', j, 'p', p, p_count_current, p_count_new)
                temp *= p_count_new+1
                temp %= mod
        dp[j] += temp
        dp[j] %= mod

ans = dp[L-1]%mod
print(ans)
0