# Recursive Statistics ## Algorithms and attribution The preferred algorithm uses differences and a multiples sieve; see [std.cpp](std.cpp). Codex (GPT-6) derives a proper-divisor recurrence from this problem's recurrence and applies the established multiples-sieve technique. The problem setter's solution uses quotient blocks with incremental memoization. See the [complete explanation](solution-alternative-quotient-blocks.en.md) and [alternative-quotient-blocks.cpp](alternative-quotient-blocks.cpp). It evaluates the recurrence directly and reads queries as a stream. The difference algorithm improves the asymptotic preprocessing time, while its supplied implementation stores the queries. ## Differences of consecutive arguments All calculations for positive arguments are modulo $P=998244353$ . Set $F(0)=0$ and define $$D(n)=F(n)-F(n-1)\pmod P\qquad(n\ge1)$$ Compare $F(n)$ with $F(n-1)$ . For $i\ge2$ , the value $\lfloor n/i\rfloor$ increases from $\lfloor(n-1)/i\rfloor$ exactly when $i$ divides $n$ . The newly introduced term $i=n$ follows the same rule because $F(0)=0$ . Thus $$D(n)=1+\sum_{\substack{i\mid n\\i\ge2}}D(n/i)=1+\sum_{\substack{d\mid n\\d --std ``` Omit `--std` to generate only inputs, or use `--case 01` to select one input. Independent checks are in [check_r15.py](../../../tools/check_r15.py). See the [five-round alternating measurements](../../../docs/benchmark-R15.json) and [environment](../../../docs/评测环境与性能.md). Finite tests and timings of these implementations supplement the proofs; they do not establish a time guarantee for every implementation with the same asymptotic bound. ## Measured Results | Program | Largest per-case median | Peak working set | | --- | ---: | ---: | | Reference | 0.044081 s | 6.46 MiB | | Alternative | 0.322212 s | 6.01 MiB | The reference limit is 0.5 seconds. Both programs agree on all ten measured formal inputs and finish within this limit. Peak working set includes process overhead; maximum time and memory may come from different inputs. Although quotient blocks have a higher asymptotic time bound, the current constraints and calibrated limit do not reliably exclude them. These measurements do not establish a separation between the algorithm classes.