Editorial
Initially, satisfies . Given an inverse of length , the Newton update
doubles the precision. A direct implementation with two full convolutions is correct, but its normalized cost is about for , so it does not receive full score.
The full-score construction recovers the required high half of from two cyclic views. Treat as a length- polynomial and truncate to length .
First compute
with a cyclic convolution of length . This uses two length- DFTs and one IDFT.
Next, let be a primitive -th root and let . Multiply coefficient by , fold modulo , and perform a cyclic convolution of length . After the inverse transform, multiply coefficient by . The result is
For , write
Then
Because , we have , so . Therefore,
The new high half in the Newton update is exactly , so compute this expression and append it to .
Each doubling step uses three transforms of length and three transforms of length . For , the total cost is
Thus, for ,
which receives full score. When is not a power of two, zero-pad at each step and truncate to length at the end.
The frequency order of DFT output is irrelevant. The construction only multiplies DFT outputs produced at the same length, so the opaque-order guarantees in the specification are sufficient.
Solution written by GPT5.6