A Negative Base ProblemProblem code: ENCD05 |
We knows about base->2 (binary) integers and base->10 (decimal) integers, and various other positive bases. But what about negative bases. OK! lets talk about the "base-> -2". An integer n written in base -2 is a sequence of digits written right-to-left. Each of which is either 0 or 1 (no negative digits!), and the following equality must hold: n = b0 + b1(-2) + b2(-2)2 + b3(-2)3 + ... The cool thing is that every integer (including the negative ones) has a unique "base-> -2" representation, with no minus sign required. Your task is to find this representation.
Input
The Input consists of the number of test cases. Each one is a line containing a decimal integer n, in the range from -1,000,000,000 to 1,000,000,000, excluding 0. Terminate the input with n=0.
Output
For each test case, output one line containing base -2 representation of the input number.
Example
Input: 1 7 -2 0 Output: 1 11011 10
| Author: | rscrbv |
| Date Added: | 19-01-2010 |
| Time Limit: | 3 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments

Fetching successful submissions

Have we to print any blank
Have we to print any blank line after the outputs or anything of that sort ?? I am quite sure my algorithm is correct but I am getting WA
we are starting to give hints
we are starting to give hints on problems:
for this problem:
it is ad-hoc, just divide the no. by -2 and proceed!!
we are starting to give hints
we are starting to give hints on problems:
for this problem:
it is ad-hoc, just divide the no. by -2 and proceed!!
Similar problem available on
Similar problem available on SPOJ .. mine got acepted there but here it's not getting AC , is thr any additional spaces / blank lines tht we need to print .Reply soon
@ishani parekh it has alredy
@ishani parekh
it has alredy been solved by many participants
plz do not write these kind of absurd comments