C87 Score 100 Time 15:41
bin_str = format(int(status[1]), 'b')
format () Integer for the first argument Mode selection for the second argument
Convert decimal numbers to binary numbers
Second argument | Conversion destination |
---|---|
b | Binary number |
x | Hexadecimal |
check_lsit[-int(target)]
If the left side of the list is a large number and the right side is a small number
list
0 | 1 | 2 | 3 |
---|---|---|---|
A | B | C | D |
When displaying A → B → C → D
python
for i in range(4):
print(list[i])
When displaying D → C → B → A If it is range (4), it will be 0 to 3 and it will be -0 -1 -2 -3 Since it will be DCB, adjust it so that it becomes -1 -2 -3 -4. (Please let me know if there is any good way.)
python
for i in range(1,5):
print(list[-i])
-4 | -3 | -2 | -1 |
---|---|---|---|
A | B | C | D |
python
input_line = input()
status = input_line.split()
bin_str = format(int(status[1]), 'b')#Point 1
check_lsit = list(bin_str)
for i in range(int(status[0])):
target = input()
print(check_lsit[-int(target)])#Point 2
Recommended Posts