Problem:


Score : 300 points

Problem Statement

Given an integer N, find the base -2 representation of N.

Here, S is the base -2 representation of N when the following are all satisfied:

S is a string consisting of 0 and 1.

Unless S = 0, the initial character of S is 1.

Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.

It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.

Constraints

Every value in input is integer.

-10^9 \leq N \leq 10^9

Input

Input is given from Standard Input in the following format:

N

Output

Print the base -2 representation of N.

Sample Input 1

-9

Sample Output 1

1011

As (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, 1011 is the base -2 representation of -9.

Sample Input 2

123456789

Sample Output 2

11000101011001101110100010101

Sample Input 3

0

Sample Output 3

0



Sample input:
-9


Sample output:
1011

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = ''
for i in range(10000):
    if n == 0:
        break
    if n % 2 ** (i + 1) == 0: 
        ans = '0' + ans
    else:
        n -= (-2)**i
        ans = '1' + ans
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = ''
for i in range(30):
    if n == 0:
        break
    if n % 2 ** (i + 1) == 0: 
        ans = '0' + ans
    else:
        n -= (-2)**i
        ans = '1' + ans
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = ''
for i in range(30):
    if n == 0:
        break
    if n % 2 ** (i + 1) == 0: 
        ans = ans + '0'
    else:
        n -= (-2)**i
        ans = ans + '1'
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=""
for i in range(50):
    if N%(-2)==0:
        S=S+"0"
    else:
        S=S+"1"
        N-=1
    N=N//(-2)
print(int(S))

Submission status: Wrong Answer

Solution code:
def m():
    n = int(input())
    L = 30
    a = [0] * L
    b = [0] * L
    b[0], b[1] = 1, -2
    ans = ["0"] * 30
    for i in range(L):
        a[i] = (-2) ** i

    for i in range(2, L):
        b[i] = a[i] + b[i-2]
    
    def solve(p):
        if p == 0:
            return
        if p < 0:
            for j in range(1, L, 2):
                if p >= b[j]:
                    p -= a[j]
                    ans[j] = "1"
                    solve(p)
                    break
        else:
            for j in range(0, L, 2):
                if p <= b[j]:
                    p -= a[j]
                    ans[j] = "1"
                    solve(p)
                    break
    solve(n)
    ans.reverse()
    return int("".join(ans))


print(m())

Submission status: Wrong Answer

Solution code:
N=int(input())
ans=""
while N!=0:
    if N%2!=0:
        
        ans="1"+ans
        N-=1
    else:
        ans="0"+ans
    N=N/-2   
print(ans)

Submission status: Wrong Answer

Solution code:
#10進数Nを逆2進数リストに変換する関数
def change_2r(N):
    if N==0:
        return [0]
    list=[]
    while N>=2:
        list.append(N%2)
        N=int((N-N%2)/2)
    list.append(1)
    return list
  
#逆2進数リストNのi-1桁目(N[i])へ繰り上がる関数
def moveup(N,i):
    if len(N)<=i:
        N.append(1)
    else:
        if N[i]==0:
            N[i]=1
        elif N[i]==1:
            N[i]=0
            moveup(N,i+1)

N=int(input())
i=0
if N>=0:
    Nlist=change_2r(N)
    while i<len(Nlist):
        if i%2!=0 and Nlist[i]==1:
            moveup(Nlist,i+1)
        i+=1
else:
    N=-N
    Nlist=change_2r(N)
    while i<len(Nlist):
        if i%2==0 and Nlist[i]==1:
            moveup(Nlist,i+1)
        i+=1
        
Nlist.reverse()
print(Nlist)
print(''.join(map(str,Nlist)))

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

k = 0
S = []
while 1:
    print(k, N)
    if N % 2 == 0:
        S.append(0)
    else:
        N -= (-1) ** k
        S.append(1)
    N /= 2
    k += 1
    if N == 0:
        break

for i in S[::-1]:
    sys.stdout.write(str(i))
sys.stdout.write('\n')

Submission status: Wrong Answer

Solution code:
n = int(input())
def divminus2(n):
    if n%2 == 1:
        q = n // -2 + 1
        r = n % 2 + 2
    else:
        q = n // -2
        r = 0
    return q,r

ans_list = []
while n != 0:
    q,r = divminus2(n)
    n = q
    ans_list.append(str(r))

ans_list.reverse()
if ans_list == []:
    print("0")
else:
    print("".join(ans_list))

Submission status: Wrong Answer

Solution code:
n = int(input())
def divminus2(n):
    if n%2 == 1:
        q = n // -2 + 1
        r = abs(n % 2)
    else:
        q = n // -2
        r = 0
    return q,r

ans_list = []
while n != 0:
    q,r = divminus2(n)
    n = q
    ans_list.append(str(r))

ans_list.reverse()
print("".join(ans_list))

Submission status: Wrong Answer

Solution code:
n = int(input())
listForA = []
while True:
    if n%2 ==0:
        listForA.append(0)
    else:
        listForA.append(1)
    sho = n//(-2)
    if sho ==0:
        break
    elif sho ==1:
        listForA.append(sho)
        break
    else:
        n = sho
listForA.append(0)
listForA.append(0)
index=0
while index < len(listForA):
    if n < 0:
        if listForA[index] ==1 and index%2 ==0:
            listForA[index+1]+=1
    else:
        if listForA[index] ==1 and index%2 ==1:
           listForA[index+1]+=1
    index+=1
count =0
flag =1
while flag:
    count+=1
    if count==6:
        break
    index=0
    while index < len(listForA)-2:
        if listForA[index]!=0 and listForA[index]!=1:
            newN = listForA[index]-2
            listForA[index] = newN
            if listForA[index+1]>0:
                listForA[index+1]-=1
            else:
                listForA[index+1]+=1
                listForA[index+2]+=1
        index+=1
    flag = 0
    for number in range(2, 10):
        if number in listForA:
            flag =1
    
if listForA[len(listForA)-1] ==0:
    del listForA[len(listForA)-1]
if listForA[len(listForA)-1] ==0:
    del listForA[len(listForA)-1]

listForA.reverse()
print("".join(map(str, listForA)))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = ""
while(n != 0):
    if n % -2 == 0:
        s  = "0" + s
    else:
        s  = "1" + s
        n = n - 1
    n //= -2
print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n > 0:key = 1
if n < 0:key = 0
lis = []
while abs(n) >= 1:
  if n % 2 == 1:
    n -= 1
    lis.insert(0,"1")
  else:
    lis.insert(0,"0")
  n = n // (-2)
if n == 0:
  lis.append("0")
print("".join(lis))

Submission status: Wrong Answer

Solution code:
n = int(input())
if n > 0:key = 1
if n < 0:key = 0
lis = []
while abs(n) >= 1:
  if n % 2 == 1:
    n -= 1
    lis.insert(0,"1")
  else:
    lis.insert(0,"0")
  n = n // (-2)

print("".join(lis))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = ''

if n == 0:
    print(0)
    exit()

i = 0
while n != 0:
    if n % (2 ** (i+1)) != 0:
        s += '1'
        n -= (-2) ** i
    else:
        s += '0'
    print(s)
    i += 1
print(s[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())

t = 0
ans = ''
while N != 0:
    a = N%2
    if t % 2 == 0:
        ans = str(int(a)) + ans
        N -= a
        N /= 2
    else:
        ans = str(int(a)) + ans
        N += a
        N /= 2
    t +=1
    print(N)
if ans == '':
    ans = '0'
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = 1
res = ""
while N != 0:
    if N % (2 * a) == 0:
        res = "0" + res
    else:
        res = "1" + res
        N -= a
    a *= -2
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N == 1:
    print('1')
if N == -1:
    print('11')
if N == -2:
    print('10')

m = 400
length = 0
for i in range(3, m):
    posneg = 1 if i % 2 == 1 else -1
    if posneg == 1 and 4**((i+1)/2 - 1) / 3 <= N and N <= 4**((i+1)/2) / 3:
        length = i
        break
    elif posneg == -1 and -(4)**((i+1)/2 - 1)/ 3 >= N and N >= -(4)**((i+1) /2) / 3:
        length = i
        break

ans = ''
for i in range(length, 2, -1):
    posneg = 1 if i % 2 == 1 else -1
    if posneg == 1:
        if 4**((i+1)/2 - 1) / 3 <= N and N <= 4**((i+1)/2) / 3:
            N -= 2**(i - 1)
            ans += '1'
        else:
            ans += '0'
    elif posneg == -1:
        if posneg == -1 and -(4)**((i+1)/2 - 1)/ 3 >= N and N >= -(4)**((i+1) /2) / 3:
            N += 2**(i - 1)
            ans += '1'
        else:
            ans += '0'

if N == 1:
    ans += '01'
if N == -1:
    ans += '11'
if N == -2:
    ans += '10'


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

Ans = ""
while N!=0:
    Ans = str(N%2) +Ans
    N = (N - N%2)//2
    N *= -1

print(Ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

print(N%(-2),N//(-2))

Ans = ""
while N!=0:
    Ans = str(N%2) +Ans
    N = (N - N%2)//2
    N *= -1

print(Ans)

Submission status: Wrong Answer

Solution code:
import math

def main():
	n = int(input())
	ans = ""

	i = 0
	while n != 0:
		print(n)
		if n % (2 ** (i + 1)) != 0:
			ans += "1"
			n -= (-2) ** i
		else:
			ans += "0"

		i += 1

	if n == 0:
		print(0)
	else:
		print(ans[::-1])

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
while n != 0:
  if n%2 ==0:
    n = n/(-2)
    a.append("0")
  else:
    n = (n-1)/(-2)
    a.append("1")
    
b = ""
for i in range(len(a)):
  b += a[len(a)-i-1]
  
print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = -2
s = ""
while n != 0:
    if n%v != 0:
        s += "1"
        n -= v//(-2)
    else:
        s += "0"
    v *= -2
print(s[::-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = ''
a = 2
while True:
	if n == 0:
		break
	if n % a == 0:
		ans += '0'
	else:
		ans += '1'
		n -= (a//2)

	n = n//2
	if a == 2:
		a = -2
	else:
		a = 2


ans = ans[::-1]
if n == 0:
	print(0)
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = ''
a = 2
while True:
	if n == 0:
		break
	if n % a == 0:
		ans += '0'
	else:
		ans += '1'
		n -= (a//2)

	n = n//2
	if a == 2:
		a = -2
	else:
		a = 2


ans = ans[::-1]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
y = int(input().split()[0])
result = ""
i = 0
while True:
    print(i)
    z = (-2) ** (i+1)
    x = y % z
    print(x)
    if x != 0:
        y = y + x
        result = "1" + result
    else:
        result = "0" + result
    if y == 0:
        break
    i = i + 1
print(result)

Submission status: Wrong Answer

Solution code:
# C
N = int(input())

if N == 0:
    print('0')
else:

    idx = 0
    while True:
        idx += 1
        left = sum([(-2)**i for i in range(idx+1) if i%2==1])
        right = sum([(-2)**i for i in range(idx+1) if i%2==0])
        if left <= N <= right:
            break

    max_idx = idx
    coeff = [0 for _ in range(max_idx+1)]
    for idx in range(max_idx, 0-1, -1):
        left = sum([(-2)**i for i in range(idx) if i%2==1])
        right = sum([(-2)**i for i in range(idx) if i%2==0])
        print(left, N, right)
        if not left <= N <= right:
            N -= (-2)**(idx)
            coeff[idx] = 1
    #     print(N)
    # print(reversed(coeff)
    print(''.join(map(str, reversed(coeff))))

Submission status: Wrong Answer

Solution code:
N = int(input())

if N == 0:
    print('0')
    exit(0)

idx = 0
while True:
    idx += 1
    left = sum([(-2)**i for i in range(idx+1) if i%2==1])
    right = sum([(-2)**i for i in range(idx+1) if i%2==0])
    if left <= N <= right:
        break
        
max_idx = idx
coeff = [0 for _ in range(max_idx+1)]
for idx in range(max_idx, 0-1, -1):
    left = sum([(-2)**i for i in range(idx) if i%2==1])
    right = sum([(-2)**i for i in range(idx) if i%2==0])
    print(left, N, right)
    if not left <= N <= right:
        N -= (-2)**(idx)
        coeff[idx] = 1
#     print(N)
# print(reversed(coeff)
print(''.join(map(str, reversed(coeff))))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    if N == 0:
        return '0'
    l = []
    while N:
        l.insert(0, str(-(N % (-2))))
        if l[0] == '1':
            N -= 1
        N = N // -2
    print("".join(l))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    if N == 0:
        return '1'
    l = []
    while N:
        l.insert(0, str(-(N % (-2))))
        if l[0] == '1':
            N -= 1
        N = N // -2
    print("".join(l))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
s = ''

while N != 0:
    print(N, s, N % (-2) == 0)
    if N % (-2) == 0:
        s = '0' + s
    else:
        s = '1' + s
        N -= 1
    N /= (-2)

if s =='':
    s = '0'
print(s)

Submission status: Wrong Answer

Solution code:
print(bin(int(input()))[2:])

Submission status: Wrong Answer

Solution code:
print(bin(int(input()))[3:])

Submission status: Wrong Answer

Solution code:
import math

# input
N = int(input())

ans = []

if N == 0:
    print(0)
else:
    while N != 1:
        if N > 0:
            n = 2 * (math.ceil(math.log(3 * N + 1, 4)) - 1) + 1 # N を -2進法で表したときの桁数
            ans.append(n - 1)
            N = N - (-2) ** (n - 1)
        else:
            n = 2 * math.floor(math.log((-3 * (N - 1) / 2) + 1, 4)) # N を -2進法で表したときの桁数
            ans.append(n - 1)
            N = N - (-2) ** (n - 1)
    ans.append(0)
    n = max(ans) + 1 # N を -2進法で表したときの桁数
    for i in range(n)[::-1]:
        if i in ans:
            print(1, end = "")
        else:
            print(0, end = "")

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
res = []

if n==0:
    print(0)
    sys.exit()
    
while n!=0:
    if n%2 == 1:
        res.append(1)
        n = (n-1)/(-2)
    else:
        res.append(0)
        n = n/(-2)

reversed(res)

for i in res:
    print(i, end="")

Submission status: Wrong Answer

Solution code:
# input
N = int(input())

if N == 0:
    print(0)
else:
    for i in range(1 << 2 * abs(N)): # bit全探索
        N_temp = N - 1
        ans = '1'
        for j in range(1, abs(2 * N)): 
            if i & (1 << j): # (-2)^{j}
                N_temp = N_temp - ((-2) ** j)
                ans = ans + '1'
            else:
                ans = ans + '0'
            if N_temp == 0:
                print(ans)
                exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
b = ''
while True:
    if abs(n) <= 1:
        b += str(n)
        break
    b += str(n % 2)
    n = (n - n % 2) // (-2)
print(b[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
rangeList = [[0, 1], [-1, -2]]
for i in range(27):
    a = (-2) ** (i+2)
    rangeList.append([a+rangeList[i+1][1], a+rangeList[i][1]])

maxPower = 0
for i in range(len(rangeList)):
    if min(rangeList[i]) <= N <= max(rangeList[i]):
        maxPower = i
        break
    
S = [0 for i in range(maxPower+1)]
sum = 0
for i in range(maxPower+1):
    mod = N % (2 ** (i+1))
    if mod - sum == 2 ** i:
        S[maxPower - i] = 1
        sum += (-2) ** i
output = ""
for i in range(len(S)):
    output += str(S[i])
print(int(output))

Submission status: Wrong Answer

Solution code:
n=bin(int(input()))
print(n)

Submission status: Wrong Answer

Solution code:
N = int(input())

x=0
s=""

while N!=0:
    x=int(N%2)
    s=str(x)+s
    N=(N-x)/-2
print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = ""
for i in range(100):
    while n != 0:
        r = (n % 2)
        n = (n - r) // (-2)
        ans = str(r) + ans
if n==0:
    print("0")
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = ""
for i in range(100):
    while n != 0:
        r = (n % 2)
        n = (n - r) // (-2)
        ans = str(r) + ans
print(ans)

Submission status: Wrong Answer

Solution code:
input()
print('11000101011001101110100010101')

Submission status: Wrong Answer

Solution code:
def determine_digit(digit_num, acm, n):
    mod = 2 ** (digit_num + 1)
    if (n - acm) % mod:
        return 1
    else:
        return 0


def convert(n):
    result = ''
    acm = 0
    digit_num = 0
    # print('n:', n)
    while n != acm:
        # print(digit_num, acm, result)
        d = determine_digit(digit_num, acm, n)
        # print('d: ', d)

        # incremental procedure
        acm += d * (-2)**digit_num
        digit_num += 1
        result += str(d)

    return result[::-1]


if __name__ == "__main__":
    n = int(input())

    print(convert(n))

Submission status: Wrong Answer

Solution code:
def determine_digit(digit_num, acm, n):
    mod = 2 ** (digit_num + 1)
    if (n - acm) % mod:
        return 1
    else:
        return 0


def convert(n):
    result = ''
    acm = 0
    digit_num = 0
    # print('n:', n)
    while n != acm:
        # print(digit_num, acm, result)
        d = determine_digit(digit_num, acm, n)
        # print('d: ', d)

        # incremental procedure
        acm += d * (-2)**digit_num
        digit_num += 1
        result += str(d)

        # guard
        if digit_num > 20:
            break

    return result[::-1]


if __name__ == "__main__":
    n = int(input())

    print(convert(n))

Submission status: Wrong Answer

Solution code:
n = int(input())

a = []

if n > 0:
    while n > 0:
        a.append(n % 2)
        n //= 2

    a.append(0)
    if len(a) % 2 == 0:
        a.append(0)
    for i in range(len(a) - 1):
        if i % 2 == 1:
            if a[i] == 1:
                a[i + 1] += 1
            elif a[i] == 2:
                a[i + 1] += 1
                a[i] = 0
        else:
            if a[i] == 2:
                a[i + 1] += 1
                a[i] = 0
        a[i] = str(a[i])

    if a[len(a) - 1] == 0:
        a[len(a) - 1] = ''
    else:
        a[len(a) - 1] = '1'
    print(''.join(reversed(a)))
elif n == 0:
    print('0')
else:
    n = 0 - n
    while n > 0:
        a.append(n % 2)
        n //= 2

    a.append(0)
    if len(a) % 2 == 0:
        a.append(0)
    for i in range(len(a) - 1):
        if i % 2 != 1:
            if a[i] == 1:
                a[i + 1] += 1
            elif a[i] == 2:
                a[i + 1] += 1
                a[i] = 0
        else:
            if a[i] == 2:
                a[i + 1] += 1
                a[i] = 0
        a[i] = str(a[i])

    if a[len(a) - 1] == 0:
        a[len(a) - 1] = ''
    else:
        a[len(a) - 1] = '1'
    print(''.join(reversed(a)))

Submission status: Wrong Answer

Solution code:
import bisect
def put(a,b):
    l=max(len(a),len(b))
    a="0"*l+a
    b="0"*l+b
    s=""
    for i in range(-1,-l-1,-1):
        s+=a[i]+b[i]
    print(s[-1::-1])

def quad(i):
    s=""
    while i>0:
        s+=str(i%4)
        i//=4
    return s[-1::-1]

l=[0,1]
for i in range(1,18):
    l+=[4**i+j for j in l]

n=int(input())
for i in range(len(l)):
    if (n-l[i])%2==0:
        ind=bisect.bisect_left(l,(l[i]-n)//2)
        if l[i]-2*l[ind]==n:
            put(quad(l[i]),quad(l[ind]))
            break

Submission status: Wrong Answer

Solution code:
import bisect
def put(a,b):
    a+="0"*20
    b+="0"*20
    s=""
    for  i in range(20):
        s+=a[i]+b[i]
    s=s[-1::-1]
    ind=s.find("1")
    if ind==-1:
        print(0)
    else:
        s=s[ind:]
        print(s[-1::-1])

def quad(i):
    s=""
    while i>0:
        s+=str(i%4)
        i//=4
    return s[-1::-1]

l=[0,1]
for i in range(1,22):
    l+=[4**i+j for j in l]

n=int(input())
for i in range(len(l)):
    if (n-l[i])%2==0:
        ind=bisect.bisect_left(l,(l[i]-n)//2)
        if l[i]-2*l[ind]==n:
            put(quad(l[i]),quad(l[ind]))
            break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    ans, m = "", 1
    while n != 0:
        m *= (-2)
        if abs(n) % abs(m) > 0:
            ans += "1"
            n -= m // (-2)
        else:
            ans += "0"
    print(ans if ans else 0)

if __name__=="__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())

if n == 0:
    print(0)

else:
    s = ''
    cnt = 1
    while n > 0:
        s += str(1) if n % (-2)**cnt != 0 else str(0)
        n -= (-2)**(cnt - 1) if n % (-2)**cnt != 0 else 0
        cnt += 1
    print(s[::-1])

Submission status: Wrong Answer

Solution code:
import math
import sys

N = int(input())

digit = []

if N == 0:
    print(0)
    sys.exit()
exp = math.ceil(math.log2(abs(N)))
if exp % 2 == 0:
    pl_s = True
else:
    pl_s = False

while N != 1:
    if pl_s == True:
        N_next = N // 2
        digit.append(str(N % 2))
        N = N_next
        pl_s = not(pl_s)
    else:
        N_next = N // (-2)
        digit.append(str(abs(N % (-2))))
        N = N_next
        pl_s = not(pl_s)
digit.append('1')
digit.reverse()
str_digit = "".join(digit)
print(str_digit)

Submission status: Wrong Answer

Solution code:
import bisect
def put(a,b):
    a+="0"*20
    b+="0"*20
    s=""
    for  i in range(20):
        s+=a[i]+b[i]
    s=s[-1::-1]
    ind=s.find("1")
    if ind==-1:
        print(0)
    else:
        s=s[ind:]
        print(s[-1::-1])

def quad(i):
    s=""
    while i>0:
        s+=str(i%4)
        i//=4
    return s[-1::-1]

l=[0,1]
for i in range(1,18):
    l+=[4**i+j for j in l]

n=int(input())
for i in range(len(l)):
    if (n-l[i])%2==0:
        ind=bisect.bisect_left(l,(l[i]-n)//2)
        if l[i]-2*l[ind]==n:
            put(quad(l[i]),quad(l[ind]))
            break

Submission status: Wrong Answer

Solution code:
n=int(input())
i=0
b=[]
q=n
ans=""

while 1:
  r=q%(-2)
  q=int(q/(-2)+0.5)
  
  if q==0:
    b.append(1)
    break
  if r==0:
    b.append(0)
  else:
    b.append(1)
  i=i+1

b.reverse()
for j in range(i+1):
  ans=ans+str(b[j])
  
print(ans)

Submission status: Wrong Answer

Solution code:
ans = ""
N = int(input())

while N != 0:
    if N % 2 != 0:
        ans = "0" + ans
        N -= 1
    else:
        ans = "1" + ans
    N /= -2
print("".join(ans))

Submission status: Wrong Answer

Solution code:
ans = ""
N = int(input())

while N != 0:
    if N % 2 == 1:
        ans = "1" + ans
        N -= 1
    else:
        ans = "0" + ans
    N /= -2
print("".join(ans))

Submission status: Wrong Answer

Solution code:
# encoding: utf-8
N = int(input())

# define L

# adjust
ans = ""
while N != 0:
    # print(N, ans)
    if N % 4 == 0:
        ans = "00" + ans
        N -= 0
    elif N % 4 == 1:
        ans = "01" + ans
        N -= 1
    elif N % 4 == 2:
        ans = "10" + ans
        N -= -2
    else:
        ans = "11" + ans
        N -= -1
    N = int(N / 4)
    
for i in range(len(ans)):
    if ans[i] != "0":
        print(ans[i:])
        break

Submission status: Wrong Answer

Solution code:
n = int(input())

ma = 50
result=[]
for i in range(ma):
  if n==(-2**i):
    result.append("1")
    break
  
  if (n%(2**(i+1)))==0:
    result.append("0")
  else:
    result.append("1")
    n-=((-2)**i)

result.reverse()
head=0
for x in result:
  if x=="1":
    break
  if x=="0" and (len(result)-1)>head:
    head+=1

print("".join(result[head:]))

Submission status: Wrong Answer

Solution code:
n = int(input())

ma = 31
result=[]
for i in range(ma):
  if n==(-2**i):
    result.append("1")
    break
  
  if (n%(2**(i+1)))==0:
    result.append("0")
  else:
    result.append("1")
    n-=((-2)**i)

result.reverse()
head=0
for x in result:
  if x=="1":
    break
  if x=="0" and (len(result)-1)>head:
    head+=1

print("".join(result[head:]))

Submission status: Wrong Answer

Solution code:
N =int(input().strip())

target = N
output_str = ""

while target != 0:
    if target % 2 == 1:
        output_str = "1" + output_str
        target = (target - 1) / (-2)
    else:
        output_str = "0" + output_str
        target = (target) / (-2)

print(output_str)

Submission status: Wrong Answer

Solution code:
n = int(input())

ma = 100
result=[]
for i in range(ma):
  if n==(-2**i):
    result.append("1")
    break
  
  if (n%(2**(i+1)))==0:
    result.append("0")
  else:
    result.append("1")
    n-=((-2)**i)

result.reverse()
print("".join(result))

Submission status: Wrong Answer

Solution code:

n = int(input())

ma = 31
result=[]
for i in range(ma):
  if n==(-2**i):
    result.append("1")
    break
  
  if (n%(2**(i+1)))==0:
    result.append("0")
  else:
    result.append("1")
    n-=((-2)**i)

result.reverse()
print("".join(result))

Submission status: Wrong Answer

Solution code:
n=int(input())
string=""

while n!=0:
    if n%2==1:
        string="1"+string
        n=n-1
    else:
        string="0"+string
    n=n/(-2)
    
print(string)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = int(input())
    for bit in range(0, 1 << 20):
        ans = "0" * 64
        ans = list(ans)
        res = 0

        base = 1
        idx = 0
        tmp_bit = bit
        while (tmp_bit > 0):
            if tmp_bit % 2 != 0:
                res += base
                ans[idx] = '1'
            tmp_bit = tmp_bit >> 1
            base *= 4
            idx += 2
        if N > res:
            continue
        
    
        for x in range(41, 0, -2):
            base = 2 ** x
            base *= -1
            if res + base >= N:
                res += base
                ans[x] = '1'
        if res == N:
            ans = "".join(reversed(ans))
            for i in range(len(ans)):
                if ans[i] == '1':
                    print (ans[i:])
                    break
            exit(0)
    print (0)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = int(input())
    for bit in range(0, 1 << 20):
        ans = "0" * 64
        ans = list(ans)
        res = 0

        base = 1
        idx = 0
        tmp_bit = bit
        while (tmp_bit > 0):
            if tmp_bit % 2 != 0:
                res += base
                ans[idx] = '1'
            tmp_bit = tmp_bit >> 1
            base *= 4
            idx += 2
        if N > res:
            continue
        
    
        for x in range(41, 0, -2):
            base = 2 ** x
            base *= -1
            if res + base >= N:
                res += base
                ans[x] = '1'
        if res == N:
            ans = "".join(reversed(ans))
            for i in range(len(ans)):
                if ans[i] == '1':
                    print (ans[i:])
                    break
            break
    print (0)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = int(input())
    for bit in range(0, 1 << 20):
        ans = "0" * 64
        ans = list(ans)
        res = 0

        base = 1
        idx = 0
        tmp_bit = bit
        while (tmp_bit > 0):
            if tmp_bit % 2 != 0:
                res += base
                ans[idx] = '1'
            tmp_bit = tmp_bit >> 1
            base *= 4
            idx += 2
        if N > res:
            continue
        
    
        for x in range(41, 0, -2):
            base = 2 ** x
            base *= -1
            if res + base >= N:
                res += base
                ans[x] = '1'
        if res == N:
            ans = "".join(reversed(ans))
            for i in range(len(ans)):
                if ans[i] == '1':
                    print (ans[i:])
                    break
            break

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = int(input())
    for bit in range(0, 1 << 16):
        ans = "0" * 64
        ans = list(ans)
        res = 0

        base = 1
        idx = 0
        tmp_bit = bit
        while (tmp_bit > 0):
            if tmp_bit % 2 != 0:
                res += base
                ans[idx] = '1'
            tmp_bit = tmp_bit >> 1
            base *= 4
            idx += 2
        if N > res:
            continue
        
    
        for x in range(31, 0, -2):
            base = 2 ** x
            base *= -1
            if res + base >= N:
                res += base
                ans[x] = '1'
        if res == N:
            ans = "".join(reversed(ans))
            for i in range(len(ans)):
                if ans[i] == '1':
                    print (ans[i:])
                    break
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = ''
while N != 0:
    bit = N % 2
    ans = str(bit) + ans
    N -= bit
    N //= -2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ret = ''
while n > 0:
  d, r = n / (-2), n % (-2)
  if r == -1: # (d+1) * (-2) + 1 = n
    r = 1
    d += 1
  ret += str(r)
  n = d
if ret == '':
  ret = '0'
else:
  ret = ret[::-1]
print(ret)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
k=0

while k<1:
    if n==0:
        k=1
    else:
        if n%2==0:
            a.append(0)
            n=n/(-2)
        else:
            a.append(1)
            n=(n-1)/(-2)
            
for i in (reversed(a)):
    print(i,end="")

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

if(N == 0):
    print(0)
    sys.exit()

ans = ""
while(N != 0):
    if(N % 2 == 0):
        ans = "0" + ans
    else:
        ans = "1" + ans
    N = N // (-2)
    # N = -1 * k

print(ans)