This page is still under construction.

Parts of this page are still being built. What you see may change.

base2i

Time limit1sMemory limit512 MB

Summary
Represent the Gaussian integer x + iy in base 2i, using digits 0 to 3 and exactly one fractional digit, and return it as a string.
Level

Medium6 of 10

Topics
Math, Number theory, Implementation, Simulation
Solved
No attempts yet

Problem

Write a function P4:

  • Mr. Park ((1+6i)(1+6i) years old) has two eyes, so he loves 2i2i. He wants to advertise the base 2i2i system.

  • In the base 2i2i system, each complex number has the following representation: [\cdots d_2d_1d_0.d_{-1}d_{-2}\cdots] which means [\cdots+d_2\cdot b^2+d_1\cdot b^1+d_0\cdot b^0+d_{-1}\cdot b^{-1}+d_{-2}\cdot b^{-2}+\cdots] where b=2ib=2i, and d_k∈{0,1,2,3}d\_k\in\{0,1,2,3\} for each kk.

  • input parameter: two integers x, y satisfying max⁡(∣\max(|x∣|,∣|y∣)≤106|)\le10^6

  • return value: the string representing the complex number x+i+iy in the base 2i2i system, satisfying the followings:

    • Each character in the string is one of '0', '1', '2', '3', '.'.
    • The string contains exactly one '.'.
    • There is exactly one character after '.'.
    • The string does not start with '.'.
    • The string does not start with '0' if there are more than one character before '.'.
  • For example, 31.0 is the base 2i2i representation of 1+6i1+6i since 1+6i=3⋅(2i)1+1⋅(2i)0+0⋅(2i)−11+6i=3\cdot(2i)^1+1\cdot(2i)^0+0\cdot(2i)^{-1}

Examples1

  1. Example 1

    Input
    0 0
    
    Expected output
    0.0