题目收集
题目列表题单
返回列表

Does It Divide?

CodeforcesP0035· 1000ms· 1024 MB· ZJU Summer 2026 Contest 3原题链接
数学

创建于 2026/07/16 · 更新于 2026/07/16

题目描述

Alice and Bob are playing a number guessing game. First, Alice chooses an unknown positive integer mmm uniformly at random from the interval [1,n][1, n][1,n] as the secret number. Then, Bob needs to determine the exact value of mmm by asking a series of questions. For each question, Bob can choose an arbitrary positive integer xxx and ask Alice: "Is mmm a multiple of xxx?" (formally, does m mod x=0m \bmod x = 0mmodx=0 hold?). Alice will answer truthfully with "Yes" or "No" to each question.

Bob wants to finish the game as quickly as possible because an upcoming Codeforces round is about to start. Therefore, he dynamically adjusts his questions based on Alice's previous answers to minimize the expected number of questions required to uniquely determine mmm.

Given the upper bound nnn, your task is to calculate this expected number of questions.

Output the answer modulo 998244353. Formally, let the exact answer be an irreducible fraction PQ\frac{P}{Q}QP​. You should output P⋅Q−1 mod 998244353P \cdot Q^{-1} \bmod 998244353P⋅Q−1mod998244353, where Q−1Q^{-1}Q−1 is the multiplicative inverse of QQQ modulo 998244353.

输入格式

The only line contains a single integer nnn (1≤n≤1071 \le n \le 10^71≤n≤107) — the upper bound of the secret number.

输出格式

Output a single integer — the minimum expected number of questions Bob needs to uniquely determine mmm, modulo 998244353.

样例输入 #1

3

样例输出 #1

665496237

样例输入 #2

7

样例输出 #2

3

样例输入 #3

1

样例输出 #3

0