Submission #2986709


Source Code Expand

Copy
n = gets.to_i
if n == 0
    puts 0
    exit
end
ans = []
i = 0
while n != 0
    if n%2 == 1
        ans[i] = 1
        n -= (i%2==0 ? 1 : -1)
    else
        ans[i] = 0
    end
    n /= 2
    i += 1
end
puts ans.reverse.join

Submission Info

Submission Time
Task C - Base -2 Number
User betrue12
Language Ruby (2.3.3)
Score 300
Code Size 242 Byte
Status
Exec Time 7 ms
Memory 1788 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02, sample_03
All 300 / 300 0_small0, 0_small1, 0_small2, 0_small3, 0_small4, 1_large0, 1_large1, 1_large2, 1_large3, 1_large4, 1_large5, 1_large6, 1_large7, 2_max0, 2_max1, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_small0 7 ms 1788 KB
0_small1 7 ms 1788 KB
0_small2 7 ms 1788 KB
0_small3 7 ms 1788 KB
0_small4 7 ms 1788 KB
1_large0 7 ms 1788 KB
1_large1 7 ms 1788 KB
1_large2 7 ms 1788 KB
1_large3 7 ms 1788 KB
1_large4 7 ms 1788 KB
1_large5 7 ms 1788 KB
1_large6 7 ms 1788 KB
1_large7 7 ms 1788 KB
2_max0 7 ms 1788 KB
2_max1 7 ms 1788 KB
sample_01 7 ms 1788 KB
sample_02 7 ms 1788 KB
sample_03 7 ms 1788 KB