본문 바로가기

python-algorithm1422

백준 10801 카드게임 https://www.acmicpc.net/problem/10801 10801번: 카드게임 두 사람 A와 B는 1부터 10까지의 숫자가 하나씩 적힌 열 장의 카드로 ‘게임’을 한다. 게임은 총 열 번의 ‘라운드’로 구성되고, 각 라운드 마다 자신이 가지고 있는 카드 중 하나를 제시하고, www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 def sol(cards_a , cards_b): win_a, win_b = 0, 0 answer = 'D' for i in range(10): if cards_a[i] > cards_b[i]: win_a+=1 elif cards_a[i] win_b: answer = 'A' elif win_a 2022. 11. 28.
백준 1408 24 https://www.acmicpc.net/problem/1408 1408번: 24 도현이는 Counter Terror Unit (CTU)에서 일하는 특수요원이다. 도현이는 모든 사건을 정확하게 24시간이 되는 순간 해결하는 것으로 유명하다. 도현이는 1시간 만에 범인을 잡을 수 있어도 잡지 않는 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 def sol(start_time , end_time): start_hh, start_mm, start_ss = map(int, start_time.split(':')) end_hh, end_mm, end_ss = map(int, end_time.split(':')) total_time = (end_hh-st.. 2022. 11. 28.
백준 5598 카이사르 암호 https://www.acmicpc.net/problem/5598 5598번: 카이사르 암호 가이우스 율리우스 카이사르(Gaius Julius Caesar)는 고대 로마 군인이자 정치가였다. 카이사르는 비밀스럽게 편지를 쓸 때, 'A'를 'D로', 'B'를 'E'로, 'C'를 'F'로... 이런 식으로 알파벳 문자를 3개씩 건 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def sol(s,shift): answer = '' for i in s : if ord(i)-shift 2022. 11. 28.
백준 15881 Pen Pineapple Apple Pen https://www.acmicpc.net/problem/15881 15881번: Pen Pineapple Apple Pen 여러 개의 사과, 파인애플, 그리고 펜이 일렬로 세워져 있다. 이 물건들의 순서를 바꾸지 않고 옆에 있는 물건끼리 연결했을 때, 펜-파인애플-애플-펜을 몇 개나 만들 수 있을지 세어보자. 단, 펜, www.acmicpc.net 1 2 3 4 5 6 7 8 9 def sol(s): return (s.count('pPAp')) if __name__ == '__main__': n= int(input()) s=input() print(sol(s)) cs 흠.. 이게 통과 됐는데 케이스가 잘못된건지.. 난이도가 잘못된건지.. 헷갈리네요 2022. 11. 26.
백준 25965 미션 도네이션 https://www.acmicpc.net/problem/25965 25965번: 미션 도네이션 리그오브전설 스트리머 순범이는 트위치 플랫폼으로 시청자를 끌어모으고 있다. 순범이는 '트윕' 음성 도네이션을 통해 시청자들과 소통하고는 한다. 순범이는 트윕에 '미션' 기능이 있다는 것 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 if __name__ == '__main__': n=int(input()) for i in range(n): m= int(input()) missions=[] for j in range(m): K,D,A= map(int,input().split()) missions.append([K,D,A]) k,d,a = map(int,input().sp.. 2022. 11. 25.
백준 17072 아스키 아트 https://www.acmicpc.net/problem/17072 17072번: 아스키 아트 위와 같이, 아스키 문자로 그린 그림을 ‘아스키 아트’ 라고 한다. 우리가 알고 있는 일반적인 그림 파일(.jpg, .png 등)들은 기본적으로 해상도에 맞게 픽셀 단위로 분할된 2차원 그리드에 대해 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 def ascii_art(r,g,b): intensity = 2126*r+7152*g+722*b if intensity 2022. 11. 25.
백준 9047 6174 https://www.acmicpc.net/problem/9047 9047번: 6174 입력은 표준입력(standard input)을 통해 받아들인다. 입력의 첫 줄에는 테스트 케이스의 개수 T(1 ≤ T ≤ 20)가 주어진다. 각 테스트 케이스마다 한 줄에 네 자리 수(1000~9999)가 하나씩 주어진다. 단, www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def sol(n): cnt = 0 while n != 6174: str_num=str(n).zfill(4) min_number = ''.join(sorted(list(str_num))) max_number = ''.join(sorted(list(str_num), reverse=True)) n = in.. 2022. 11. 25.
백준 25703 포인터 공부 https://www.acmicpc.net/problem/25703 25703번: 포인터 공부 용모는 오늘 객체지향프로그래밍1 시간에 포인터에 대해 배웠다. 포인터란, 프로그래밍 언어에서 다른 변수, 혹은 그 변수의 메모리 공간주소를 가리키는 변수를 의미한다. C/C++에서 포인터는 ( www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def sol(n): print('int a;') print('int *ptr = &a;') if n==2: print('int **ptr2 = &ptr;') elif n>=3: print('int **ptr2 = &ptr;') for i in range(3,n+1): star = '*'*i print('int %sptr%d = &ptr%d.. 2022. 11. 24.
백준 14626 ISBN https://www.acmicpc.net/problem/14626 14626번: ISBN ISBN(International Standard Book Number)은 전 세계 모든 도서에 부여된 고유번호로, 국제 표준 도서번호이다. ISBN에는 국가명, 발행자 등의 정보가 담겨 있으며 13자리의 숫자로 표시된다. 그중 마지막 숫 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 def sol(isbn): check_sum = 0 answer = 0 for i in range(12): if i%2 ==0 : multiple = 1 else: multiple = 3 if isbn[i].isnumeric(): check_sum+=int.. 2022. 11. 24.
백준 25932 Find the Twins https://www.acmicpc.net/problem/25932 25932번: Find the Twins Print each input set. Then, on the next output line, print one of four messages (mack, zack, both, none), indicating how many of the twins are in the set. Leave a blank line after the output for each test case. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 if __name__ == '__main__': n = int(input()) for _ in range(n): answer = 'n.. 2022. 11. 16.
백준 11121 Communication Channels https://www.acmicpc.net/problem/11121 11121번: Communication Channels The first line of the input consists of a single number T, the number of transmissions. Then follow T lines with the input and the output of each transmission as binary strings, separated by a single space. 0 < T ≤ 100 All inputs and outputs has length l www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(origin,changed): for i in .. 2022. 11. 15.
백준 8718 Bałwanek https://www.acmicpc.net/problem/8718 8718번: Bałwanek W pierwszym wierszu wejścia znajdują się dwie liczby całkowite x, k (1 ≤ x ≤ 106, 1 ≤ k ≤ 105, k < x), oznaczające odpowiednio ilość litrów śniegu w parku oraz z ilu litrów śniegu zbudowana jest jedna z kul śnieżnych bałwana. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(n,k): answer =[] n= n*1000 k= k*1000 answer = 0 answer_list = .. 2022. 11. 15.