본문 바로가기

전체 글1523

백준 30045 ZOAC 6 https://www.acmicpc.net/problem/30045 30045번: ZOAC 6 2023년 9월, 여섯 번째로 개최된 ZOAC의 오프닝을 또 맡은 성우는 영과일의 마스코트인 영일이를 이용해 대회를 홍보하기로 했다. 성우는 홍보 글이 주어질 때 각 문장에 01 또는 OI가 포함되어 있다 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(strings): answer = 0 for i in strings: if '01' in i or 'OI' in i: answer += 1 return answer if __name__ == '__main__': n = int(input()) strings = [input() for i in range(n)].. 2023. 12. 20.
백준 30468 호반우가 학교에 지각한 이유 1 https://www.acmicpc.net/problem/30468 30468번: 호반우가 학교에 지각한 이유 1 첫 번째 줄에 $STR,\,DEX,\,INT,\,LUK$과 $N$이 공백을 두고 주어진다. $(1 \le STR,\,DEX,\,INT,\,LUK,\,N \le 100)$ 입력되는 모든 수는 양의 정수이다. www.acmicpc.net 123456789101112def sol(s, d, i, l, n): stats = n * 4 - sum((s, d, i, l)) if stats >= 0: return stats else: return 0 if __name__ == '__main__': s, d, i, l, n = map(int, input().split()) print(sol(s, d, i,.. 2023. 12. 20.
백준 1120 문자열 https://www.acmicpc.net/problem/1120 1120번: 문자열 길이가 N으로 같은 문자열 X와 Y가 있을 때, 두 문자열 X와 Y의 차이는 X[i] ≠ Y[i]인 i의 개수이다. 예를 들어, X=”jimin”, Y=”minji”이면, 둘의 차이는 4이다. 두 문자열 A와 B가 주어진다. 이때, A의 www.acmicpc.net 1234567891011121314def sol(a, b): scores = [] for i in range(len(b) - len(a) + 1): score = 0 for j in range(len(a)): if a[j] != b[i + j]: score += 1 scores.append(score) return min(scores) a, b = input.. 2023. 12. 6.
백준 25178 두라무리 휴지 https://www.acmicpc.net/problem/25178 25178번: 두라무리 휴지 기령이는 어느 날 캠릿브지 대학의 연결구과에 대해 알게 되었다. 캠릿브지 대학의 연결구과란, 단어를 이해함에 있어 한 단어 안에서 글자들이 어떤 순서로 배열되어 있는지는 중요하지 않고, www.acmicpc.net 123456789101112131415161718192021222324252627282930313233343536373839def sol(s1, s2): def first(s1, s2): if sorted(s1) == sorted(s2): return True else: return False def second(s1, s2): if s1[0] == s2[0] and s1[-1] == s2[-1]:.. 2023. 12. 6.
백준 20114 미아 노트 https://www.acmicpc.net/problem/20114 20114번: 미아 노트 첫째 줄에 원래 문자열의 길이 N, 세로로 번진 글자의 개수 H, 가로로 번진 글자의 개수 W가 주어진다. (1 ≤ N ≤ 100, 1 ≤ H ≤ 10, 1 ≤ W ≤ 10) 둘째 줄부터 H개의 줄에 걸쳐 N × W 길이의 문자열이 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 def sol(strings): for i in strings: if i != '?': return i return '?' n, h, w = map(int, input().split()) alpha = [''] * n for i in range(h): s = input() fo.. 2023. 12. 6.
백준 17091 단어 시계 https://www.acmicpc.net/problem/17091 17091번: 단어 시계 첫째 줄에 시를 나타내는 h(1 ≤ h ≤ 12), 둘째 줄에 분을 나타내는 m(0 ≤ m < 60)이 주어진다. www.acmicpc.net 12345678910111213141516171819202122232425262728293031323334def sol(h, m): hs = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one'] ms = [" o' clock", "one", "two", "three", "four", "five", "six", "seven".. 2023. 12. 6.
백준 9324 진짜 메시지 https://www.acmicpc.net/problem/9324 9324번: 진짜 메시지 스파이들은 사령부와 통신하기 위해서 SMTP(비밀 메시지 전송 프로토콜)를 사용해 비밀 회선으로 전자 메시지를 보낸다. 메시지가 적들에 의해 조작되어 보내진 것이 아닌 진짜 메시지라는 것 www.acmicpc.net 12345678910111213141516171819202122232425def sol(s): alpha = [0] * 26 check = False for i in range(len(s)): if check: check = False continue alpha[ord(s[i]) - 65] += 1 if alpha[ord(s[i]) - 65] == 3: if i == len(s) -1: return '.. 2023. 12. 6.
백준 7656 만능 오라클 https://www.acmicpc.net/problem/7656 7656번: 만능 오라클 입력은 한 줄로 된 1000자 이내의 단락이 주어진다. 포함된 문자는 대소문자, 띄어쓰기, 하이픈(hyphen), 어퍼스트로피(apostrophe), 반점(comma), 세미콜론(semicolon), 온점(period)과 물음표(question mark)이다. www.acmicpc.net 1234567891011121314def sol(s): start = end = -1 while s.find('What', end + 1) != -1: start = s.find('What', end + 1) end = s.find('?', start + 1) new_s = s[start:end] if new_s.find('.').. 2023. 12. 6.
백준 30868 개표 https://www.acmicpc.net/problem/30868 30868번: 개표 투표가 끝난 뒤에는 개표를 해야 한다. 일반적으로 개표는 칠판을 사용하며, 한 표가 나올 때마다 한 획을 추가로 긋는 방식을 사용한다. 이 문제에서는 다음과 같은 방식으로 개표를 진행한다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 def sol(n): answer = [] while n >= 5: answer.append('++++') n -= 5 if n >= 1: answer.append('|' * n) return answer if __name__ == '__main__': t = int(input()) for i in range(t): n = int.. 2023. 12. 4.
백준 5949 Adding Commas https://www.acmicpc.net/problem/5949 5949번: Adding Commas Bessie is working with large numbers N (1 2023. 11. 29.
백준 8892 팰린드롬 https://www.acmicpc.net/problem/8892 8892번: 팰린드롬 팰린드롬은 어느 방향으로 읽어도 항상 같은 방법으로 읽을 수 있는 단어이다. 예를 들어, civic, radar, rotor, madam은 팰린드롬이다. 상근이는 단어 k개 적혀있는 공책을 발견했다. 공책의 단어는 ICPC 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 from itertools import permutations def check(s): if (s[0] + s[1]) == (s[0] + s[1])[::-1]: return s[0] + s[1] else: return False def solutio.. 2023. 11. 29.
백준 10448 유레카 이론 https://www.acmicpc.net/problem/10448 10448번: 유레카 이론 프로그램은 표준입력을 사용한다. 테스트케이스의 개수는 입력의 첫 번째 줄에 주어진다. 각 테스트케이스는 한 줄에 자연수 K (3 ≤ K ≤ 1,000)가 하나씩 포함되어있는 T개의 라인으로 구성되어 www.acmicpc.net 12345678910111213141516171819202122from itertools import combinations_with_replacement def solution(n): eureka = [1, 3, 6] start = 4 while n >= eureka[-1]: eureka.append(eureka[-1] + start) start += 1 pro = list(combin.. 2023. 11. 28.