結果

問題 No.3505 Sum of Prod of Root
コンテスト
ユーザー tyuyu_62
提出日時 2026-04-18 11:29:22
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,729 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 335 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2026-04-18 11:29:45
合計ジャッジ時間 3,911 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# snippet: templete_
# Last Modified: 2026-02-13

from collections import deque, defaultdict
from itertools import permutations, product
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop
from random import randint, shuffle
from time import perf_counter as pc
def II(): return int(input())
def LI(): return list(map(int,input().split()))
def LI_1(): return [int(x) - 1 for x in input().split()]
def SI(): return input()
def LS(): return list(input().split())
mod = 998244353
inf = 1001001001001001001

import sys
sys.setrecursionlimit(10 ** 6)
input = lambda: sys.stdin.readline().rstrip()
_buf = []
def print(*a, **k): _buf.append(" ".join(map(str, a)))

# snippet: isqrt_
# Last Modified: 2026-02-12
from math import sqrt
def isqrt(x):
    y = int(sqrt(x))
    while (y + 1) * (y + 1) <= x:
        y += 1
    while y * y > x:
        y -= 1
    return y
def solve():
    N = min(mod - 1, II())
    res = [1] * 30
    cnt = 1
    d = defaultdict(list)
    d[1] = []
    d[N + 1] = []
    for i in range(2, isqrt(N) + 1):
        x = i * i
        for j in range(2, 30):
            d[x].append((i, j))
            x *= i
            if x > N:
                break
    ans = 0
    key = sorted(d.keys())
    # print(key)
    for i in range(len(key) - 1):
        l = key[i + 1] - key[i]
        ans = (ans + cnt * ((key[i + 1] - key[i]) * (key[i + 1] + key[i] - 1) // 2 % mod)) % mod
        for x, j in d[key[i + 1]]:
            res[j] = x
        cnt = 1
        for j in range(30):
            cnt *= res[j]
            cnt %= mod
    print(ans)
    return

if __name__ == "__main__":
    T = 1
    # T = II()
    for _ in range(T):
        solve()
    sys.stdout.write("\n".join(_buf) + "\n")
0