프로그래밍98 2089번 : -2진수 # -2진수 n=int(input()) answer='' if n==0: print(0) while n!=0: if n%-2 == -1: n=n//-2+1 answer='1'+answer else: n//=-2 answer='0'+answer print(answer) 2022. 7. 23. 10866번 : 덱 # 덱 import sys n=int(sys.stdin.readline()) Deque=[] for i in range(n): order=sys.stdin.readline().split() if order[0]=="push_front": Deque.insert(0, order[1]) elif order[0]=="push_back": Deque.append(order[1]) elif order[0]=="pop_front": if len(Deque) != 0: print(Deque[0]) del(Deque[0]) else: print(-1) elif order[0]=="pop_back": if len(Deque) != 0: print(Deque[-1]) del(Deque[-1]) else: print(-1).. 2022. 7. 22. 10845번 : 큐 # 큐 import sys queue=[] n=int(sys.stdin.readline()) for i in range(n): order= sys.stdin.readline().split() if order[0]=="push": queue.append(order[1]) elif order[0]=="pop": if len(queue) !=0: print(queue[0]) del(queue[0]) else: print(-1) elif order[0]=="size": print(len(queue)) elif order[0]=="empty": if len(queue)==0: print(1) else: print(0) elif order[0]=="front": if len(queue) != 0: print(que.. 2022. 7. 21. 1929번 : 소수 구하기 #소수 구하기 import sys M,N=map(int, sys.stdin.readline().split()) alpha=[False, False] + [True] *(N-1) prime_number=[] for i in range(2, N+1): if alpha[i]==True: prime_number.append(i) for j in range(2*i, N+1, i): alpha[j]=False for i in prime_number: if M 2022. 7. 20. 이전 1 2 3 4 ··· 25 다음