Submission #4075670
Source Code Expand
N = int(input()) if N == 0: print(0) exit() L = [] M = [] for length in range(1,41): if length % 2 == 0: l = -2 * pow(4,length//2) // 3 m = (pow(4,length//2) - 1) // 3 elif length % 2 == 1: l = -2 * (pow(4,(length-1)//2) - 1) // 3 m = (pow(4,(length+1)//2) - 1) // 3 L.append(l) M.append(m) identify = [] for i in range(40): if i == 0: ap_list = [L[0],M[0]] elif i % 2 == 1: ap_list = [L[i],L[i-1]] elif i % 2 == 0: ap_list = [M[i-1],M[i]] identify.append(ap_list) bit = [0]*40 for i in range(39,-1,-1): left = identify[i][0] right = identify[i][1] if i % 2 == 0 and left < N <= right: bit[39-i] = 1 N -= pow(-2,i) elif i % 2 == 1 and left <= N < right: bit[39-i] = 1 N -= pow(-2,i) ans = "".join(str(e) for e in bit).lstrip("0") print(ans)
Submission Info
Submission Time | |
---|---|
Task | C - Base -2 Number |
User | pynomi |
Language | Python (3.4.3) |
Score | 300 |
Code Size | 929 Byte |
Status | AC |
Exec Time | 18 ms |
Memory | 3064 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01, sample_02, sample_03 |
All | 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 | AC | 18 ms | 3064 KB |
0_small1 | AC | 18 ms | 3064 KB |
0_small2 | AC | 18 ms | 3064 KB |
0_small3 | AC | 18 ms | 3064 KB |
0_small4 | AC | 18 ms | 3064 KB |
1_large0 | AC | 18 ms | 3064 KB |
1_large1 | AC | 18 ms | 3064 KB |
1_large2 | AC | 17 ms | 3064 KB |
1_large3 | AC | 17 ms | 3064 KB |
1_large4 | AC | 18 ms | 3064 KB |
1_large5 | AC | 17 ms | 3064 KB |
1_large6 | AC | 18 ms | 3064 KB |
1_large7 | AC | 17 ms | 3064 KB |
2_max0 | AC | 18 ms | 3064 KB |
2_max1 | AC | 18 ms | 3064 KB |
sample_01 | AC | 18 ms | 3064 KB |
sample_02 | AC | 17 ms | 3064 KB |
sample_03 | AC | 17 ms | 3064 KB |