結果

問題 No.2902 ZERO!!
ユーザー cleanttedcleantted
提出日時 2023-09-12 20:46:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,540 ms / 2,000 ms
コード長 2,774 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 260,608 KB
最終ジャッジ日時 2024-06-08 00:17:30
合計ジャッジ時間 26,889 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
90,448 KB
testcase_01 AC 157 ms
90,624 KB
testcase_02 AC 1,540 ms
259,200 KB
testcase_03 AC 158 ms
90,472 KB
testcase_04 AC 503 ms
119,680 KB
testcase_05 AC 814 ms
142,272 KB
testcase_06 AC 1,467 ms
260,608 KB
testcase_07 AC 540 ms
128,128 KB
testcase_08 AC 1,354 ms
259,968 KB
testcase_09 AC 1,317 ms
252,288 KB
testcase_10 AC 1,016 ms
210,048 KB
testcase_11 AC 872 ms
146,940 KB
testcase_12 AC 265 ms
98,616 KB
testcase_13 AC 1,343 ms
256,512 KB
testcase_14 AC 1,065 ms
213,376 KB
testcase_15 AC 1,195 ms
230,528 KB
testcase_16 AC 764 ms
137,756 KB
testcase_17 AC 1,309 ms
250,112 KB
testcase_18 AC 1,263 ms
245,376 KB
testcase_19 AC 1,136 ms
226,816 KB
testcase_20 AC 980 ms
199,936 KB
testcase_21 AC 1,050 ms
211,456 KB
testcase_22 AC 606 ms
133,504 KB
testcase_23 AC 793 ms
140,460 KB
testcase_24 AC 173 ms
91,264 KB
testcase_25 AC 176 ms
91,392 KB
testcase_26 AC 171 ms
91,388 KB
testcase_27 AC 176 ms
91,264 KB
testcase_28 AC 173 ms
91,064 KB
testcase_29 AC 179 ms
91,008 KB
testcase_30 AC 177 ms
91,392 KB
testcase_31 AC 176 ms
91,136 KB
testcase_32 AC 174 ms
91,008 KB
testcase_33 AC 180 ms
91,008 KB
testcase_34 AC 165 ms
90,312 KB
testcase_35 AC 180 ms
91,136 KB
testcase_36 AC 178 ms
91,008 KB
testcase_37 AC 177 ms
91,392 KB
testcase_38 AC 177 ms
91,008 KB
testcase_39 AC 165 ms
90,496 KB
testcase_40 AC 165 ms
90,112 KB
testcase_41 AC 165 ms
90,496 KB
testcase_42 AC 177 ms
91,264 KB
testcase_43 AC 165 ms
90,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import bisect
import copy
import heapq
import itertools
import math
import operator
import random
import sys
from bisect import bisect, bisect_left, bisect_right, insort
from collections import Counter, deque
from fractions import Fraction
from functools import cmp_to_key, lru_cache, partial
from inspect import currentframe
from math import ceil, gcd, log10, pi, sqrt
from typing import Iterable, Iterator, List, Tuple, TypeVar, Union

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
# import string
# import networkx as nx
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
# mod = 10 ** 9 + 7
mod = 998244353
# mod = 1 << 128
# mod = 10 ** 30 + 1
INF = 1 << 61
DIFF = 10 ** -9
DX = [1, 0, -1, 0, 1, 1, -1, -1]
DY = [0, 1, 0, -1, 1, -1, 1, -1]

def read_values(): return tuple(map(int, input().split()))
def read_index(): return tuple(map(lambda x: int(x) - 1, input().split()))
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for _ in range(N)]
def dprint(*values): print(*values, file=sys.stderr)
def dprint2(*values):
    names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    dprint(", ".join(f"{names.get(id(value), '???')}={repr(value)}" for value in values))

def solve(N):
    t = 1
    for i in range(1, N + 1):
        t *= i
    
    res = 0
    for b in range(2, t + 1):
        k = 0
        while t % (b ** k) == 0:
            k += 1
        # if k > 1:
        #     print(b, k - 1)
        res += k - 1
    return res


def main():
    N = int(input())
    # print(solve(N))

    P = []
    F = [False] * (N + 1) 
    for i in range(2, N + 1):
        if F[i]:
            continue
        F[i] = True
        P.append(i)
        for j in range(i, N + 1, i):
            F[j] = True

    C = []
    for p in P:
        c = 0
        r = p
        while N >= r:
            c += N // r
            r *= p
        C.append(c)
    # print(C)

    r = 1
    tmp = 0
    D = []
    for c in C:
        d = [0]
        for i in range(1, c + 1):
            k = c // i
            d.append(k)
        r *= len(d)
        tmp += len(d)
        r %= mod
        D.append(list(reversed(d)))
    # print(r, D)

    Inv = [0] + [pow(i, mod - 2, mod) for i in range(1, N + 1)]
    I = [0] * len(P)
    res = 0
    for n in range(1, N + 1):
        for k in range(len(D)):
            if D[k][I[k]] == 0:
                break
            while D[k][I[k]] == n:
                t = len(D[k]) - I[k]
                r *= Inv[t]
                r %= mod
                # print(n, k, I[k], r)
                res += r * n % mod
                res %= mod
                r *= (t - 1)
                r %= mod
                I[k] += 1
    print(res)


if __name__ == "__main__":
    main()
0