본문 바로가기

백준1056

백준 1524 세준세비 https://www.acmicpc.net/problem/1524 1524번: 세준세비 첫째 줄에 테스트 케이스의 개수 T가 주어진다. T는 100보다 작거나 같다. 각 테스트 케이스는 다음과 같이 이루어져 있다. 첫째 줄에 N과 M이 들어오고, 둘째 줄에는 세준이의 병사들의 힘이 들어 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 from sys import stdin from collections import deque def sol(sejun, sebi): answer = 'C' while len(sejun)!=0 and len(sebi)!=0: if sejun[0]len(sebi): answer =.. 2022. 11. 13.
백준 20546 🐜 기적의 매매법 🐜 https://www.acmicpc.net/problem/20546 20546번: 🐜 기적의 매매법 🐜 1월 14일 기준 준현이의 자산이 더 크다면 "BNP"를, 성민이의 자산이 더 크다면 "TIMING"을 출력한다. 둘의 자산이 같다면 "SAMESAME"을 출력한다. 모든 결과 따옴표를 제외하고 출력한다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 def bnp(cash, stocks): current_stocks=0 for current_price in stocks: current_stocks += cash//current_.. 2022. 11. 12.
백준 2422 한윤정이 이탈리아에 가서 아이스크림을 사먹는데 https://www.acmicpc.net/problem/2422 2422번: 한윤정이 이탈리아에 가서 아이스크림을 사먹는데 첫째 줄에 정수 N과 M이 주어진다. N은 아이스크림 종류의 수이고, M은 섞어먹으면 안 되는 조합의 개수이다. 아래 M개의 줄에는 섞어먹으면 안 되는 조합의 번호가 주어진다. 같은 조합은 두 번 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 if __name__ == '__main__': n, m=map(int,input().split()) icecream=[[True for i in range(n)] for i in range(n)] for i in range(m): flavor_one, flavor_two = map(int,input(.. 2022. 11. 10.
백준 1969 DNA https://www.acmicpc.net/problem/1969 1969번: DNA DNA란 어떤 유전물질을 구성하는 분자이다. 이 DNA는 서로 다른 4가지의 뉴클레오티드로 이루어져 있다(Adenine, Thymine, Guanine, Cytosine). 우리는 어떤 DNA의 물질을 표현할 때, 이 DNA를 이루는 뉴클레오 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 from collections import Counter def cal_hamming(dna,target): hamming = 0 for compared_dna in dna: for i in range(len(target)): if compared_dna[i.. 2022. 11. 10.
백준 11576 Base Conversion https://www.acmicpc.net/problem/11576 11576번: Base Conversion 타임머신을 개발하는 정이는 오랜 노력 끝에 타임머신을 개발하는데 성공하였다. 미래가 궁금한 정이는 자신이 개발한 타임머신을 이용하여 500년 후의 세계로 여행을 떠나게 되었다. 500년 후의 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 if __name__ == '__main__': a,b=map(int,input().split()) m=int(input()) original_number=0 future_number=list(map(int,input().split())) for i in range(m): tmp_num=future_number[i] or.. 2022. 11. 10.
백준 18258 큐 2 https://www.acmicpc.net/problem/18258 18258번: 큐 2 첫째 줄에 주어지는 명령의 수 N (1 ≤ N ≤ 2,000,000)이 주어진다. 둘째 줄부터 N개의 줄에는 명령이 하나씩 주어진다. 주어지는 정수는 1보다 크거나 같고, 100,000보다 작거나 같다. 문제에 나와있지 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import sys from collections import deque n=int(input()) commands=deque() for i in range(n): command = sys.stdin.readline().. 2022. 11. 9.
백준 1620 나는야 포켓몬 마스터 이다솜 https://www.acmicpc.net/problem/1620 1620번: 나는야 포켓몬 마스터 이다솜 첫째 줄에는 도감에 수록되어 있는 포켓몬의 개수 N이랑 내가 맞춰야 하는 문제의 개수 M이 주어져. N과 M은 1보다 크거나 같고, 100,000보다 작거나 같은 자연수인데, 자연수가 뭔지는 알지? 모르면 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 import sys n , m =map(int,sys.stdin.readline().split()) pokemon = dict() for i in range(1,n+1): name = sys.stdin.readline().rstrip() pokemon[name] = i pokemon_reversed = dict(ma.. 2022. 11. 9.
백준 4949 균형잡힌 세상 https://www.acmicpc.net/problem/4949 4949번: 균형잡힌 세상 하나 또는 여러줄에 걸쳐서 문자열이 주어진다. 각 문자열은 영문 알파벳, 공백, 소괄호("( )") 대괄호("[ ]")등으로 이루어져 있으며, 길이는 100글자보다 작거나 같다. 각 줄은 마침표(".")로 끝난다 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 while True: answer = 'yes' s=input() if s=='.': break stack=[] for i in s: if i=='(' or i=='[': stack.append(i) if i==')': if len(stack) != 0 and stack.. 2022. 11. 9.
백준 18398 HOMWRK https://www.acmicpc.net/problem/18398 18398번: HOMWRK In one of the beautiful cities of Afghanistan two sisters are going to program a simple game to help them solve their mathematics homework. Their homework asks them to calculate the sum and multiplication of two numbers. Your task is to help them to build www.acmicpc.net 1 2 3 4 5 6 t=int(input()) for j in range(t): n=int(input()) for i in ran.. 2022. 11. 9.
백준 1966 프린터 큐 https://www.acmicpc.net/problem/1966 1966번: 프린터 큐 여러분도 알다시피 여러분의 프린터 기기는 여러분이 인쇄하고자 하는 문서를 인쇄 명령을 받은 ‘순서대로’, 즉 먼저 요청된 것을 먼저 인쇄한다. 여러 개의 문서가 쌓인다면 Queue 자료구조에 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 from collections import deque for i in range(int(input())): n, m = map(int, input().split()) waiting= deque(list(map(int,input().split()))) importance = deque(list([i for i in range(n)]).. 2022. 11. 8.
백준 10816 숫자 카드 2 https://www.acmicpc.net/problem/10816 10816번: 숫자 카드 2 첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. 숫자 카드에 적혀있는 수는 -10,000,000보다 크거나 같고, 10, www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import sys from collections import Counter n=int(sys.stdin.readline()) cards=list(map(int, sys.stdin.readline().split())) m=int(sys.stdin.readline()) to_find=list(map(i.. 2022. 11. 8.
백준 11866 요세푸스 문제 0 https://www.acmicpc.net/problem/11866 11866번: 요세푸스 문제 0 첫째 줄에 N과 K가 빈 칸을 사이에 두고 순서대로 주어진다. (1 ≤ K ≤ N ≤ 1,000) www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 from collections import deque n, k =map(int,input().split()) nums=[i+1 for i in range(n)] nums = deque(nums) answer = [] while nums: for i in range(k-1): nums.append((nums.popleft())) answer.append(nums.popleft()) answer = map(str, answer) p.. 2022. 11. 8.