Editorial for Inaho VI

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Ninjaclasher

Without prior knowledge on the basics of complex numbers, this problem is impossible to solve. For example, it must be known that and that the rectangular coordinate form of a complex number is .

For the first subtask, since , we can utilize a simple if statement. If , the solution is . If , the solution is simply .

For the second subtask, some quick Googling will give the solutions to when and when . When , the solution is . When , the solution is . Alternatively, one can solve for when and manually using Euler's formula.

For the third subtask, one can utilize a for loop that iterates from to . Start with floating-point variables, set to , and set to . At each iteration of the for loop, it can be found that: and .

Alternatively, one can utilize a complex numbers library in their preferred programming language.

For the last subtask, one can figure out that solution converges to approximately , which means that after a certain , the solution becomes consistent up to decimal places. This means that we can hard code a value instead of looping up to . This certain and the proof is left as an exercise for the reader.

Time Complexity: 