파이썬127 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. 6588번 : 골드바흐의 추측 import sys r= 1000000 check = [True for _ in range(r)] for i in range(2,int(r**0.6)): if check[i]==True: for j in range(i*2, r, i) : if check[j] == True : check[j] = False while(True): n = int(sys.stdin.readline()) if not n : break for i in range(3,r): if check[i] == True: if check[n-i] == True : print(n, '=', i, '+', n-i) break 2022. 7. 19. 4948번 : 베르트랑 공준 # 베르트랑 공준 while 1: n = int(input()) if (n != 0 and n > 1): result_sub = 0 result = [] for i in range(n+1, n*2+1): for j in range(2, n): if i % j == 0: result_sub = 0 break else: result_sub = i if result_sub != 0: result.append(result_sub) print(len(result)) elif n == 1: print(n) else: break 2022. 7. 17. 이전 1 ··· 4 5 6 7 8 9 10 ··· 32 다음