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:
import numpy as np
n = int(input())

def plus_idx(num):
  return 2 * int(np.ceil(np.log2(1 + 3*num)/2)) - 2

def minus_idx(num):
  return 2 * int(np.ceil(np.log2(1 + 3 * abs(num) / 2)/2)) - 1

def return_idx(num):
  if num == 0:
    return 0
  elif num > 0:
    return plus_idx(num)
  else:
    return minus_idx(num)
    
def minus_two_recur(num, l):
  if num == 0:
    return 0, l
  elif num > 0:
    idx = plus_idx(num)
    l[-(idx+1)] = 1
    new_num = num - (-2)**idx
    return new_num, l
  elif num < 0:
    idx = minus_idx(num)
    l[-(idx+1)] = 1
    new_num = num - (-2)**idx
    return new_num, l

num = n
max_length = return_idx(num)
result = [0] * (max_length+1)
result[-max_length-1] = 1
while num != 0:
  num, result = minus_two_recur(num, result)

print("".join(map(str,result)))

Submission status: Wrong Answer

Solution code:
from math import ceil

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

ans=''

while n!=0:
    ans+=str(abs(n)%2)
    n=ceil(n/-2)
    print(n)
print(ans[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = ''
while N != 0:
    r = N % 2
    N = (N - r) // (-2)
    ans += str(r)

ans[::-1]
if ans == '':
    ans = '0'

print(ans)

Submission status: Wrong Answer

Solution code:
# base -k representation of n
def f(n, k):
    if n == 0:
        return []
    r = n % k
    return f(-(n - r) // k, k) + [r]

N = int(input())
print("".join(map(str, f(N, 2))))

Submission status: Wrong Answer

Solution code:
a = int(input())
if a == 0:
    print("0")
else:
    digits = []*10
    base = 1
    i = 0
    while a != 0:
        if a%(base*2) == 0:
            digits.append('0')
        else:
            digits.append('1')
            a -= base
        i += 0
        base *= -2
    print(''.join(digits))

Submission status: Wrong Answer

Solution code:
# INPUT
# 普通の入力
n = int(input())

# PROCESS
answer = ""
t = 2
if n % 2 == 0:
  answer += "0"
else:
  answer = answer + "1"
  n -= 1

while(n != 0):
  amari = n % 4
  if (amari == 0):
    answer = "00" + answer
  if (amari == 1):
    answer = "11" + answer
    n -= 1
  if (amari == 2):
    answer = "10" + answer
    n -= 2
  if (amari == 3):
    answer = "01" + answer
    n += 1
  n = n // 4

# OUTPUT
print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = ""
if N == 1:
    print("1")
elif N == 0:
    print("0")
else:
    while N != 1:
        if abs(N)%2 == 1:
            N = (N-1)//(-2)
            S += "1"
        else:
            N = N//(-2)
            S += "0"
S += "1"
print(S[::-1])

Submission status: Wrong Answer

Solution code:
x = int(input())
ans = []
while abs(x) > 1:
    ans.append(abs(x % -2))
    x //= -2
print(''.join([str(i) for i in ans + [abs(x)]]))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())

    rev_answer = ""
    while N != 0:
        rem = N % (-2)
        if rem < 0:
            rem += 2
        N = (N - rem) // (-2)
        rev_answer += str(rem)

    answer = rev_answer[::-1]
    print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
if N == 0:
    print(0)
else:
    li = []
    ind = 0
    while N != 0:
        if N % 2**(ind + 1) == 0:
            li.insert(0,0)
            ind += 1
        else:
            li.insert(0,1)
            N -= (-2)**(ind)
            ind += 1            
            x = ''.join([str(li[i]) for i in range(len(li))])
            print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = []
tmp = 0

def algo(n):
    if n == 0:
        return
    
    if n%2 == 0:
        tmp = 0 #tmpは毎回のa0に値する
    else:
        tmp = 1
    ans.append(tmp)
    algo((n-tmp)//(-2))

algo(N)
Str = ''
ans.reverse()
for i in range(len(ans)):
    Str=Str+str(ans[i])
print(Str)

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = []
tmp = 0

def algo(n):
    if n == 0:
        return
    
    if n%2 == 0:
        tmp = 0 #tmpは毎回のa0に値する
    else:
        tmp = 1
    ans.append(tmp)
    algo((n-tmp)//(-2))

algo(N)
Str = ''
for i in range(len(ans)):
    Str=Str+str(ans[i])
print(Str)

Submission status: Wrong Answer

Solution code:
N = int(input())


def calc_digits(n):
    i = 0
    if n > 0:
        while (4**(i+1) - 1) / 3 < n:
            i += 1

        return 2*i+1
    else:
        while (-2) * ((4**i - 1) / 3) > n:
            i += 1

        return 2 * i


def calc(n):
    p = calc_digits(n)
    a = ['0'] * p
    a[0] = '1'
    n -= (-2)**(p-1)
    for i in range(1, p):
        if n == 0:
            break

        item = (-2)**(p-i-1)
        if (item > 0 and n > 0) or (item < 0 and n < 0):
            a[i] = '1'
            n -= item
        else:
            a[i] = '0'

    return ''.join(a)


def main():
    if N == 0:
        return 0
    else:
        return calc(N)


print(main())

Submission status: Wrong Answer

Solution code:
N = int(input())
s = []
for i in range(100):
    if N % (2 ** (i+1)) != 0:
        N -= (-2) ** i
        s.append('1')
    else:
        s.append('0')

s.reverse()
print(s)
t = ''.join(s)
print(int(t))

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = ''
i = 0
while not n == 0:
    i += 1
    if n % 2 == 0:
        ans = '0' + ans
    else:
        ans = '1' + ans
        n += (-1) ** i
    n //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
n=-int(input())
a=""
while n:
    a+=str(n%2)
    n//=-2
print(a[::-1] if n else 0)

Submission status: Wrong Answer

Solution code:
a=int(input())
if a==-1:
    print("11")
    exit()
b=""
c=2
d=0
n=0
if a > 0:
    m=a
else:
    m=-a-1
while m >d:
    if (a-d-1)%c < c//2:
        b+="1"
    else :
        b+="0"
    c*=2
    n=1-n
    d=d+(3*d+1)*n
if a < 0:
    if b[-1]=="0":b=b[:-1]
    if (a-d-1)%c < c//2:
        b+="1"

print(b[::-1])

Submission status: Wrong Answer

Solution code:
N=int(input())
bit_list=[]
x=N

if N == 0:
    print(0)
else:
    while(abs(x)!=1):
        bit_list.insert(0,str(x%2))
        x=-(x//2)
    bit_list.insert(0,'1')
    if N > 0: bit_list.insert(0,'1')

    ans=''.join(bit_list)
    print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
bit_list=[]
x=N

if N == 0:
    print(0)
    
while(abs(x)!=1):
    bit_list.insert(0,str(x%2))
    x=-(x//2)
bit_list.insert(0,'1')
if N > 0: bit_list.insert(0,'1')

ans=''.join(bit_list)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
bit_list=[]
x=N

if N < 0:
    while(abs(x)!=1):
        bit_list.insert(0,str(x%2))
        x=-(x//2)
    bit_list.insert(0,'1')
    ans=''.join(bit_list)
    print(ans)

elif N > 0:
    while(abs(x)!=1):
        bit_list.insert(0,str(x%2))
        x=-(x//2)
    bit_list.insert(0,'1')
    bit_list.insert(0,'1')
    ans=''.join(bit_list)
    print(ans)

else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
bit_list=[]
x=N
i=1 #i回目の割り算

if N < 0:
    while(x!=1 and x!=-1):
        bit_list.insert(0,str(x%2))
        i+=1
        if i%2==0:
            x=abs(x//2)
        else:
            x=-(x//2)
    bit_list.insert(0,'1')
    ans=''.join(bit_list)
    print(ans)

elif N > 0:
    while(x!=1):
        bit_list.insert(0,str(x%2))
        x=x//2
    bit_list.insert(0,'1')
    bit_list.insert(0,'1')
    ans=''.join(bit_list)
    print(ans)

else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
bit_list=[]
x=N
i=1 #i回目の割り算

if N < 0:
    while(x!=1 or x!=-1):
        bit_list.insert(0,str(x%2))
        i+=1
        if i%2==0:
            x=abs(x//2)
        else:
            x=-(x//2)
    bit_list.insert(0,'1')
    ans=''.join(bit_list)
    print(ans)

elif N > 0:
    while(x!=1):
        bit_list.insert(0,str(x%2))
        x=x//2
    bit_list.insert(0,'1')
    bit_list.insert(0,'1')
    ans=''.join(bit_list)
    print(ans)

else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
bit_list=[]
x=N
i=1 #i回目の割り算

if N < 0:
    while(x!=1):
        bit_list.insert(0,str(x%2))
        i+=1
        if i%2==0:
            x=abs(x//2)
        else:
            x=-(x//2)
    bit_list.insert(0,'1')
    ans=''.join(bit_list)
    print(ans)

elif N > 0:
    while(x!=1):
        bit_list.insert(0,str(x%2))
        x=x//2
    bit_list.insert(0,'1')
    bit_list.insert(0,'1')
    ans=''.join(bit_list)
    print(ans)

else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

li1 = [0]* 20
li2 = [0]* 20
count = 1

for i in range(19):
    li1[i+1] = li1[i] + 4 ** i
    li2[i+1] = li2[i] - 2 * 4 ** i

if n == 0:
    s = [0]
elif n > 0:
    for i in range(20):
        if li1[i] < n and li1[i+1] >= n:
            a = i
            s = [0] * (2*i+1)
            s[0] = 1
            n -= (-2) ** (2*i)
            break
    while a > 0:
        a -= 1
        if li2[a] > n and li2[a+1] <= n:
            s[count] = 1
            n -= (-2) ** (2*a+1)
            count += 1
        else:
            s[count] = 0
            count += 1
        if li1[a] < n and li1[a+1] >= n:
            s[count] = 1
            n -= (-2) ** (2*a)
            count += 1
        else:
            s[count] = 0
            count += 1
else:
    for i in range(20):
        if li2[i] > n and li2[i+1] <= n:
            a = i
            s = [0] * (2*(i+1))
            s[0] = 1
            n -= (-2) ** (2*i+1)
            break
    if li1[a] < n and li1[a] >= n:
        s[count] = 1
        n -= (-2) ** (2*a)
        count += 1
    else:
        s[count] = 0
        count += 1
    while a > 0:
        a -= 1
        if li2[a] > n and li2[a+1] <= n:
            s[count] = 1
            n -= (-2) ** (2*a+1)
            count += 1
        else:
            s[count] = 0
            count += 1
        if li1[a] < n and li1[a+1] >= n:
            s[count] = 1
            n -= (-2) ** (2*a)
            count += 1
        else:
            s[count] = 0
            count += 1

ans = ''

for i in range(len(s)):
    ans = ans + str(s[i])

print(ans)

Submission status: Wrong Answer

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

while N != 0:
    temp = 0 if N % -2 == 0 else 1
    ans = str(temp) + ans
    N -= temp
    N //= -2
    
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
"""解説

 1  0  1 1
-8  4 -2 1
----------
-8 + -2 + 1 = -9

                    1   -2    4    -8      16
1のとき表現できる数  1~1 -2~1  2~5 -10~-3   6~21
0のとき表現できる数  0~1  0~1 -2~1  -2~5  -10~5
                   ----------------------------
                   0~1  -2~1 -2~5 -10~5  -10~21      


(1) -9のときを考える
-9は2で割り切れないので、0bit目は必ず1になる。(※1)

-9を-2進数で表現すると、 

?????1

になるはず。

ということは?????0は-10である。

?????の部分はいくつか？と考えたとき、
一桁減らすので、-2で割るとよい。（-2進数なので。10進数のときは10で割るでしょ？）

よって、?????の部分は5

(2) 5のときを考える
5は2で割り切れないので、0bit目は必ず1になる(※2)

5を-2進数で表現すると、

????1

になる。

ということは????0は4である。

????の部分はいくつか？と考えたとき、
一桁減らすので、-2で割る。

よって、????の部分は-2

(3) -2のときを考える
-2は2で割り切れるので、0bit目は0である。(※3)

-2を-2進数で表現すると、

???0

???の部分はいくつか？と考えたとき、
一桁減らすので、-2で割る。

よって、???の部分は1

(4) 1のときを考える
1は2で割り切れないので、0bit目は1(※4)

1を-2進数で表現すると、

??1

??0は0

??の部分はいくつか？と考えたとき、当然0でしょう。

よって、答えは、
(※4)(※3)(※2)(※1)で、
1011
になる。

この一連の計算を一般化すればよい。

"""
def solve():
    N = int(input())
    ans = ""

    while N!=0:
        if N%2 != 0:
            # 2で割り切れない
            ans = "1" + ans
            N -= 1
            N //= -2
        else:
            ans = "0" + ans
            N //= -2
    
    print(ans)



if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def c():
   
    K = int(input())
    ans = ""
    while True:
        amari = -1*(K%-2) 
        # print(amari,end = "")
        ans += str(amari)
        K = (K-amari) / (-2)
        K = int(K)
        # print("K=",K)
        if K == 0 or K == 1:
            break
    ans += str(K)
    print(ans[::-1])
if __name__ == '__main__':
    c()

Submission status: Wrong Answer

Solution code:
import math

def dnt(n):
    if n >= 0:
        return (-1) * (n // 2)
    else:
        return math.ceil((-1) * (n / 2))

N = int(input())
S = ""

while N != 1:
    if N % 2 == 1:
        S = "1" + S
    else:
        S = "0" + S
    N = dnt(N)
    print(N)

print("1"+S)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[]

next_step=n
while True:
    ans.append(abs(next_step%2))
    if next_step in [-1,0,1]:
        break
    next_step//=2
    next_step*=-1
ans.reverse()
print(''.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
a=int(input())
l=[]
if a==0:
  print(a)
else:
  while a!=1:
    if a<0:
      l.append(abs(a)%2)
      if abs(a)%2==1:
        a=abs(a-1)//2
      else:
        a=abs(a)//2
    elif a>0:
      l.append(a%2)
      a=-(a//2)
  l.append(a)
  s=""
  for i in l:
    s+=str(i)
  print(s)

Submission status: Wrong Answer

Solution code:
a=int(input())
l=[]
if a==0:
  print(a)
else:
  while a!=1:
    if a<0:
      l.append(abs(a)%2)
      if abs(a)%2==1:
        a=abs(a-1)//2
      else:
        a=abs(a)//2
    elif a>0:
      l.append(-(a%2))
      a=-(a//2)
  l.append(a)
  s=""
  for i in l:
    s+=str(i)
  print(s)

Submission status: Wrong Answer

Solution code:
def getBaseM2Num(n):
  if n == 0:
    return 0
  
  #下位ビットから計算していく
  base = 1
  b2 = []
  while n != 0:
    if n % (2*base) == 0:
      #2のcnt乗で割り切れると、下からcntビット目は０
      b2.insert(0,"0")
    else:
      #割り切れない場合は1
      b2.insert(0,"1")
      n -= base
      
    base *= -2
  print(b2)  
  return "".join(b2)

n = int(input())
print(getBaseM2Num(n))

Submission status: Wrong Answer

Solution code:
N = int( input() )


ans = ''
while N:
    ans = str(abs(N % (-2))) + ans
    N = - (N//2)
    # print(N,ans)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

Nb = bin(N)
Nb = Nb[2+1*int(N<0):]
L = len(Nb)
ans = 0

def bitadd(S,k):
    S = list(reversed(str(S)))
    k = list(reversed(str(k)))
    if len(S) > len(k):
        k += [0] * (len(S)-len(k))
    else:
        S += [0] * (len(k)-len(S))
    ans = 0
    i = 0
    while i < min(len(S),len(k)):
        if S[i] == '1' and k[i] == '1':
            tmp = 10 ** (i+2) + 10 ** (i+1)
            ans = bitadd(ans,tmp) 
        elif S[i] == '1' or k[i] == '1':
            ans += 10 ** (i)
        i += 1
    return ans
   

if N >= 0:
    for i in range(L):
        if Nb[L-1-i] == '1':
            if i%2 == 0:
                k = 10 ** i 
            else:
                k = 10**(i+1) + 10 ** i
            ans = bitadd(ans,k)                
            
if N < 0:
    for i in range(L):
        if Nb[L-1-i] == '1':
            if i%2 == 1:
                k = 10 ** i 
            else:
                k = 10**(i+1) + 10 ** i
            ans = bitadd(ans,k)         
            
            
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,i,a,r=int(input()),0,0,1
while n:
  r*=-2;i-=1
  if (n-r)%(-2*r)==0:a+=10**i;n-=r
print(a)

Submission status: Wrong Answer

Solution code:
n,i,a=int(input()),0,0
while n:
  r=-2**i
  if (n-r)%(-2*r)==0:
    a+=10**i;n-=r
  i+=1
print(a)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[]
if n==0:
  ans.append("0")
elif n<0:
  n=abs(n)
  while n>0:
    if n%4==2:
      ans.append("10")
    elif n%4==1:
      ans.append("11")
    n//=4
else:
  if n%2==1:
    ans.append("1")
  else:
    ans.append("0")
  n//=2
  while n>0:
    if n%4==2:
      ans.append("10")
    elif n%4==1:
      ans.append("11")
a=""
for i in range(len(ans)-1,-1,-1):
  a+=ans[i]
print(a)

Submission status: Wrong Answer

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

while(N != 0):
    if N % 2:
        N -= 1
        N //= -2
        str += '1'
    else:
        N //= -2
        str += '0'
        
if N == 0:
    print(0)
else:
    print(str[::-1])

Submission status: Wrong Answer

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

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

print(str[::-1])

Submission status: Wrong Answer

Solution code:
n=abs(int(input()))
m=n
i=0
nn=0
while m//2>0:
  if i%2==0:
    nn+=m%2*(2**(i+1))
  i+=1
  m//=2
n+=nn
a=[]
while n//2>2:
  a.append(n%2)
  n//=2
ans=""
for i in range(len(a)-1,-1,-1):
  ans+=str(a[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n=abs(int(input()))
m=n
i=0
nn=0
while m//2>0:
  nn+=m%2*(2**(i+1))
  i+=1
  m//=2
n+=nn
a=[]
while n//2>2:
  a.append(n%2)
  n//=2
ans=""
for i in range(len(a)-1,-1,-1):
  ans+=str(a[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n=abs(int(input()))
m=n
i=0
nn=0
while m//2>0:
  nn+=m%2*(2**i)
  i+=1
  m//=2
n+=nn
a=[]
while n//2>2:
  a.append(n%2)
  n//=2
ans=""
for i in range(len(a)-1,-1,-1):
  ans+=str(a[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

i = 1
ans = ''
while n != 0:
  pi = pow(-1, i-1) * pow(2, i)
  if n % pi == pi // 2:
    ans += '1'
    n -= pi // 2
  else:
    ans += '0'
  i += 1
if n == 0:
  print(0)
else:
  print(ans[::-1])

Submission status: Wrong Answer

Solution code:
N=int(input())
S=""
i=0
while(N):
    if (N-(-2)**i)%2**(i+1)==0:
        S+="1"
        N-=(-2)**i
    else:
        S+="0"
    i+=1
S=S[::-1]
I=False
t=0
for i in S:
    if i=="1":
        break
    else:
        t+=1
print(S[t:])

Submission status: Wrong Answer

Solution code:
N=int(input())
S=""
i=0
while(N):
    if (N-(-2)**i)%2**(i+1)==0:
        S+="1"
        N-=(-2)**i
    else:
        S+="0"
    i+=1
print(S[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = []

while N != 0:
  if N < 0:
    N = abs(N)+2
  b = N % 2
  N = N // (-2)
  ans.append(b)
  #print(N,b,ans)

ans = map(str, ans)
ans_str = "".join(ans)
print(ans_str[::-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

while N:
    if N % 2:
        N -= 1
        ans += '1'
    else:
        ans += '0'
    N //= -2
if len(ans):
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = ''
n = 0
while N != 0:
    b = '0' if N % (2**(n + 1)) == 0 else '1'
    a += b
    N -= ((-2)**n) * int(b)
    n += 1
print(a[::-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
i = 1
ans = ''
while n != 0:
    if n % i == 0 and n % (i * -2) != 0:
        n -= i
        ans += '1'
    else:
        ans += '0'
    i *= -2
print(ans[::-1])

Submission status: Wrong Answer

Solution code:
import numpy as np


N = input()
N = int(N)

def make_base_list(N):
    # N > 0
    base_list = np.zeros(60)
    for i in range(59, -1, -1):
        if 2**i <= N:
            base_list[i] += 1
            N = N % 2**i

    for i in range(1, 59, 2):
        if base_list[i] > 0:
            base_list[i+1] += 1

    for i in range(60):
        if base_list[i] > 1:
            if base_list[i + 1] == 1:
                base_list[i] = 0
                base_list[i+1] = 0
            else:
                base_list[i] -= 2
                base_list[i+1] += 1
                base_list[i+2] += 1
    # print(base_list[::-1])
    return base_list

def neg_make_base_list(N):
    # N < 0
    base_list = np.zeros(100)

    while(N<0):
        base = 0
        for i in range(1, 59, 2):
            base += (-2) ** i
            if base < N:
                break
        base_list[i] += 1
        # print(i)
        N = N - (-2)**i
    # print(base_list[::-1])

    for i in range(59, -1, -1):
        if 2**i <= N:
            base_list[i] += 1
            N = N % 2**i
    # print(base_list[::-1])

    for i in range(60):
        if base_list[i] > 1:
            if base_list[i + 1] == 1:
                base_list[i] = 0
                base_list[i+1] = 0
            else:
                base_list[i] -= 2
                base_list[i+1] += 1
                base_list[i+2] += 1
    # print(base_list[::-1])
    return base_list


def base_list_to_str(list):
    list = list.astype(np.int32)
    list = list[::-1].tolist()
    list_ = []
    append = False
    for i in range(len(list)):
        if list[i] > 0 or append:
            append = True
        if append:
            list_.append(list[i])
    return ''.join([str(n) for n in list_])

if __name__ == '__main__':
    if N == 0:
        print(str(0))
    elif N > 0:
        print(base_list_to_str(make_base_list(N)))
    else:
        print(base_list_to_str(neg_make_base_list(N)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = ""
while n != 0:
  if n == 0:
    ans += "0"
    break
  if n % -2 == 0:
    ans += "0"
  else:
    n-=1
    ans += "1"
  n //= -2
  
print(ans[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
if N == 0:
    print("0")
a = []
#N = abs(N)
for i in range(1000000000):
    if N == 0:
        break
    else:
        if abs(N) % pow(2,i+1) != 0:
            a.append(1)
            N -= pow(-2,i)
        else:
            a.append(0)
        #print(N)
#print(a)
s = 0
for i in range(len(a)):
    s += a[i] * pow(10,i)
print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 0:
	print(0)
	exit()
res = ""
while True:
	if n == 0:
		break
	else:
		if n%2 == 0:
			res += '0'
		else:
			res += '1'
			n -= 1
		n //= -2
		print(n)
print(res[::-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
res = ""
while True:
	if n == 0:
		break
	else:
		if n%2 == 0:
			res += '0'
		else:
			res += '1'
			n -= 1
		n //= -2
print(res[::-1])

Submission status: Wrong Answer

Solution code:
N=int(input())
P=N
Q=0
R=0
L=''
while abs(P)>1:
    if P%2==0:
        Q=P/(-2)
        L+='0'
    else:
        Q=(P-1)/(-2)
        L+='1'
    P=Q
if P==1:
    L+='1'
else:
    L+='11'
ans=L[::-1]
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[]
j=0
while sum(l[i]*(-2)**i for i in range(len(l)))!=N:
  if sum(l[i]*(-2)**i for i in range(len(l)))%((-2)**(j+1))==N%((-2)**(j+1)):
    l.append(0)
  else:
    l.append(1)
  j+=1
print(''.join(map(str,reversed(l))))

Submission status: Wrong Answer

Solution code:
n = int(input())
base = 2
ans =""

while n != 0:
  ans = str(n%base)+ans
  n = -(n//base)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 1
ans = []
while N != 0:
    if N % (-2 ** i) == 0:
        ans.append(0)
    else:
        ans.append(1)
        N -= ((-2)**(i-1))
    i += 1
print("".join(map(str, ans))[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 1
ans = []
while N != 0:
    if N % (-2 ** i) == 0:
        ans.append(0)
    else:
        ans.append(1)
        N -= ((-2)**(i-1))
    i += 1
print("".join(map(str, ans)))

Submission status: Wrong Answer

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

while abs(n) > 0:
    if(abs(n) % 2 == 0):
        s = "0" + s
    else:
        s = "1" + s
        n -= 1
    n = n // (-2)
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = ""
while N != 0:
    b = N % 2
    ans += str(b)
    N = (N - b) // -2

print(ans[::-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 0:
  print(0)
  exit()
ans = ""
for i in range(1, 31):
  if n%-2 < 0:
    r = n%-2+2
    n = n//-2+1
  else:
    r = n%-2
    n = n//-2
  ans += str(r)
print(int(ans[::-1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []
i=2
j=0
k = 0
while True:
    if k==n:
        break
    if (n-k)%i==0:
        ans.append(0)
    else:
        k += i>>1 if j%2==0 else -i>>1
        ans.append(1)
    i = i<<1
    j+=1
for i in ans[::-1]:
    print(i,end='')
print()

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []
i=2
j=0
k = 0
while True:
    if k==n:
        break
    if (n-k)%i==0:
        ans.append(0)
    else:
        k += i>>1 if j%2==0 else -i>>1
        ans.append(1)
    print(k)
    i = i<<1
    j+=1
for i in ans[::-1]:
    print(i,end='')
print()

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = ""
while N != 0:
    r = int(N % (-2))
    ans = str(abs(r)) + ans
    N = (N + r) / (-2)
    #print(r, int(N))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans=[]
while not(n==0):
    amari=-(n%(-2))
    shou=(n-amari)//(-2)
    n=shou
    ans.append(str(amari))
ans=[ans[-i-1] for i in range(len(ans))]
print(''.join(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
tmp=n
i=0
while abs(tmp)>=(2**i):
    if tmp%(2**(i+1))!=0:
        l.append(1)
        tmp=tmp-(-2)**i
        i+=1
    else:
        l.append(0)
        i+=1
l=l[::-1]
l=map(str,l)
l="".join(l)
print(l)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
tmp=n
i=0
while abs(tmp)>=(2**(i-1)):
    if tmp%(2**(i+1))!=0:
        l.append(1)
        tmp=tmp-(-2)**i
        i+=1
    else:
        l.append(0)
        i+=1
l=l[::-1]
l=map(str,l)
l="".join(l)
print(l)

Submission status: Wrong Answer

Solution code:
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  ans = ''
  while N != 0:
    if N % 2 == 0:
      ans = '0' + ans
      N //= -2
    else:
      ans = '1' + ans
      N = (N - 1) // -2
  print(ans)


if __name__ == '__main__':
  main()

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-=1
  n//=-2
print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np
from functools import reduce

n = int(input())

X = 35
i = np.arange(X, dtype=np.int64)[::-1]
# 別法：i = np.flip(np.arange(X))

i = (-2)**i
print(i.dtype)

ans = np.zeros(X, dtype=np.int64)

for digit in range(X):

	i[digit]
	sum_of_opposite = i[digit+1::2].sum() # 反対符号の和

	if i[digit] > 0 and i[digit] + sum_of_opposite > n:
		ans[digit] = 0
	elif i[digit] < 0 and i[digit] + sum_of_opposite < n:
		ans[digit] = 0
	else:
		ans[digit] = 1
		n -= i[digit]

# ansの先頭の0を削除して、桁をつなげる
print(int(reduce(lambda x, y: str(x) + str(y), ans)))

Submission status: Wrong Answer

Solution code:
import numpy as np
from functools import reduce

n = int(input())

X = 30
i = np.arange(X)[::-1]
# 別法：i = np.flip(np.arange(X))

i = (-2)**i

ans = np.zeros(X, dtype=np.int32)

for digit in range(X):

	i[digit]
	sum_of_opposite = i[digit+1::2].sum() # 反対符号の和

	if i[digit] > 0 and i[digit] + sum_of_opposite > n:
		ans[digit] = 0
	elif i[digit] < 0 and i[digit] + sum_of_opposite < n:
		ans[digit] = 0
	else:
		ans[digit] = 1
		n -= i[digit]

# ansの先頭の0を削除して、桁をつなげる
print(int(reduce(lambda x, y: str(x) + str(y), ans)))

Submission status: Wrong Answer

Solution code:
N = int(input())
tmp = ''
while N:
  if(N%2 == 0):
    tmp += '0'
  else:
    tmp += '1'
  N -= 1
  N //= -2
print(tmp[::-1])

Submission status: Wrong Answer

Solution code:
from itertools import permutations


class Solver(object):
    def __init__(self):
        self.n = int(input())

    def solve(self):
        number_string = ""
        n = -self.n
        while True:
            remainder = abs(n % (-2))
            number_string = str(remainder) + number_string
            quotient = n // (-2)
            if quotient == 0:
                break
            n = quotient
        if number_string == "":
            print("0")
        else:
            print(number_string.lstrip("0"))


if __name__ == "__main__":
    s = Solver()
    s.solve()

Submission status: Wrong Answer

Solution code:
from itertools import permutations


class Solver(object):
    def __init__(self):
        self.n = int(input())

    def solve(self):
        number_string = ""
        n = self.n
        while True:
            remainder = abs(n % (-2))
            number_string = str(remainder) + number_string
            quotient = n // (-2)
            if quotient == 0:
                break
            n = quotient
        if number_string == "":
            print("0")
        else:
            print(number_string.lstrip("0"))


if __name__ == "__main__":
    s = Solver()
    s.solve()

Submission status: Wrong Answer

Solution code:
n=int(input())
L=[]
if n==0:
    print('0')
else:    
    while n!=0:
        if n>0 and n%2==0:
            n=-n//2
            L.append('0')
        elif n>0 and n%2==1:
            n=(-n+1)//2
            L.append('1')
        elif n<0 and -n%2==0:
            n=-n//2
            L.append('0')
        elif n<0 and -n%2==1:
            n=(-n+1)//2
            L.append('1')
        print(n)
    print(L)
    print(int(''.join(L[::-1])))

Submission status: Wrong Answer

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