Submission #2996519


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

long long n;
string s;

int main() {
  cin >> n;
  if(n == 0) s = '0';
  while(n != 0) {
    if(max(n, -n) % 2 != 0) {
      s += '1';
      --n;
    }
    else
      s += '0';
    n /= -2;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}

Submission Info

Submission Time
Task C - Base -2 Number
User m_tsubasa
Language C++14 (GCC 5.4.1)
Score 300
Code Size 327 Byte
Status
Exec Time 1 ms
Memory 256 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 1 ms 256 KB
0_small1 1 ms 256 KB
0_small2 1 ms 256 KB
0_small3 1 ms 256 KB
0_small4 1 ms 256 KB
1_large0 1 ms 256 KB
1_large1 1 ms 256 KB
1_large2 1 ms 256 KB
1_large3 1 ms 256 KB
1_large4 1 ms 256 KB
1_large5 1 ms 256 KB
1_large6 1 ms 256 KB
1_large7 1 ms 256 KB
2_max0 1 ms 256 KB
2_max1 1 ms 256 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB