https://www.acmicpc.net/problem/16506
구현 문제여서 노가다성 문제인듯하다
num = int(input())
opcode_machine = {'ADD':'0000', 'SUB':'0001', 'MOV':'0010', 'AND':'0011','OR':'0100',
'NOT':'0101','MULT':'0110', 'LSFTL':'0111', 'LSFTR':'1000',
'ASFTR':'1001','RL':'1010','RR':'1011'}
for i in range(num):
opcode, x, y, z = input().split()
result = ''
if opcode[-1]=='C':
result += opcode_machine.get(opcode[:-1])
result += '1'
else:
result += opcode_machine.get(opcode)
result += '0'
result += '0'
result += str(bin(int(x)))[2:].zfill(3)
result += str(bin(int(y)))[2:].zfill(3)
if result[4]=='0':
result+=str(bin(int(z)))[2:].zfill(3)
result+='0'
else:
result+=str(bin(int(z)))[2:].zfill(4)
print(result)
'백준' 카테고리의 다른 글
[백준] 11724번: 연결 요소의 개수 (파이썬) (0) | 2024.11.29 |
---|---|
[백준] 11659번: 구간 합 구하기 4(파이썬) (1) | 2024.11.23 |
[백준] 3986번: 좋은 단어(파이썬) (4) | 2024.11.21 |
[백준] 13567번: 로봇 (0) | 2024.11.19 |
[백준] 14493번: 과일노리(파이썬) (1) | 2024.10.25 |