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

Solution in C (GCC 5.4.1) (judge verdict: Accepted)

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_DIGIT_MAX		35										// 最大桁数

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 対象値 - 取得
	long long llVal;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld", &llVal);

//	llVal = 17;

	// 桁毎の値範囲セット
	long long ll1RngS[D_DIGIT_MAX];
	long long ll1RngE[D_DIGIT_MAX];
	ll1RngS[0] = 1;
	ll1RngE[0] = 1;
	ll1RngS[1] = -2;
	ll1RngE[1] = -1;
	long long llTwo = 4;
	for (i = 2; i < D_DIGIT_MAX; i++) {
		if (llTwo > 0) {
			ll1RngS[i] = ll1RngE[i - 2] + 1;
			ll1RngE[i] = ll1RngE[i - 2] + llTwo;
		}
		else {
			ll1RngS[i] = ll1RngS[i - 2] + llTwo;
			ll1RngE[i] = ll1RngS[i - 2] - 1;
		}

		llTwo *= -2;									// 次へ
	}

	// 開始桁取得
	int liDNo = 0;
	llTwo = 1;
	if (llVal != 0) {
		for (i = 0; i < D_DIGIT_MAX; i++) {
			if (ll1RngS[i] <= llVal && llVal <= ll1RngE[i]) {
				liDNo = i;
				break;
			}
			else {
				llTwo *= -2;									// 次へ
			}
		}
	}

	// 算出
	int liSNo = 0;
	for (i = liDNo; i >= 0; i--) {
		if (ll1RngS[i] <= llVal && llVal <= ll1RngE[i]) {
			lc1Out[liSNo] = '1';
			llVal -= llTwo;									// 現在値更新
		}
		else {
			lc1Out[liSNo] = '0';
		}

		liSNo++;
		llTwo /= -2;									// 次へ
	}

	// 改行
	lc1Out[liSNo] = '\n';
	lc1Out[liSNo + 1] = '\0';

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}