#P10321. 奉献(Dedication)

    ID: 11504 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学数论洛谷原创Special JudgeO2优化素数判断,质数,筛法最大公约数 gcd洛谷比赛

奉献(Dedication)

Background

A mathematical spirit of constantly pushing yourself forward — dedication.


"Light of Dedication" Lisa is both a priest of "God of Order" Paila and a believer of "God of Disorder" Dionysus.

Lisa recently studied high-precision division. She can compute division of an nn-digit integer in Θ(nlogn)\Theta(n \log n) time complexity.

Problem Description

Lisa wants to make a division table for positive integers up to nn. Specifically, it is a table that records a/b\lfloor a/b \rfloor (1ban1\leq b \leq a \leq n, and a,ba,b are both integers). She makes it using the following method:

Enumerate positions (a,b)(a,b) in increasing order with aa as the primary key and bb as the secondary key. If position (a,b)(a,b) is not filled, then:

Compute a/b\lfloor a/b \rfloor. The mana cost for this is dalog2dad_a \log_2 d_a (where dad_a is the number of decimal digits of aa, i.e., da=1+log10ad_a=\lfloor 1+ \log_{10}a\rfloor). Then enumerate positive integers ii, and for all not filled positions (ai,bi)(ai,bi) (ainai\leq n), fill them with a/b\lfloor a/b \rfloor. Each fill costs mana did_i.

Since Mena has already made a multiplication table, Lisa can compute multiplication directly without any mana cost. Now Lisa wants to know how much mana is needed to make the entire division table.

To avoid precision issues, your output is considered correct as long as its relative error from the standard output does not exceed 10610^{-6}. It is guaranteed that the relative error between the standard output and the actual answer does not exceed 101010^{-10}.

Input Format

One line with a positive integer nn, indicating that you want to make a division table of size nn.

Output Format

One line with a real number, representing the answer.

6
21.0000000
20
422.0000000
233
99838.0384544

Hint

[Sample 11 Explanation]

Since a6a \leq 6, da=1d_a=1, so dalog2da=0d_a \log_2 d_a=0. That is, within this range only filling numbers costs mana. Also, each ii is at most 66, so di=1d_i=1, and each fill costs a fixed 11 mana point. Filling all 1+2+3+4+5+6=211+2+3+4+5+6=21 numbers costs 2121 mana.

Therefore, the answer is 2121.

[Constraints]

This problem uses bundled testdata.

Subtask 1 (15 pts): n5000n\le 5000;
Subtask 2 (15 pts): n105n\le 10^5;
Subtask 3 (30 pts): n2×106n\le 2 \times 10^6;
Subtask 4 (40 pts): no special constraints.

For all testdata, 1n2×1071\le n \le 2 \times 10^7.

[Hint]

log2n\log_2 n is read as “the logarithm of nn with base 22”. Let x=log2nx=\log_2n, which means 2x=n2^x=n.

Translated by ChatGPT 5