본문 바로가기

백준1056

백준 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.
백준 18141 Are They All Integers? https://www.acmicpc.net/problem/18141 18141번: Are They All Integers? Computing using integers is a dream for every programmer. That is, you do not have to deal with floating point numbers, estimated errors, and etc. We do not even need any floating point units in our computers for divisions! Your company claimed there is a www.acmicpc.net 1234567891011121314from itertools import permutationsdef .. 2023. 11. 28.
백준 15122 Forbidden Zero https://www.acmicpc.net/problem/15122 15122번: Forbidden Zero You’re writing the positive integers in increasing order starting from one. But you’ve never learned the digit zero, and thus omit any number that contains a zero in any position. The first ten integers you write are: 1, 2, 3, 4, 5, 6, 7, 8, 9, and 11. www.acmicpc.net 123456789def solution(s): s = str(int(s) + 1) return s.replace('0','.. 2023. 11. 28.
백준 16283 Farm https://www.acmicpc.net/problem/16283 16283번: Farm 입력은 표준입력을 사용한다. 첫 번째 줄에 네 정수 a, b, n, w가 한 줄에 주어진다. 1 ≤ a ≤ 1,000, 1 ≤ b ≤ 1,000, 2 ≤ n ≤ 1,000, 2 ≤ w ≤ 1,000,000이다. www.acmicpc.net 1234567891011121314151617def solution(a, b, n, w): answer = [] for x in range(1, n): if a * x + (n - x) * b == w: answer.append((x, n - x)) if len(answer) == 1: return answer[0] else: return [-1] if __name__ == '_.. 2023. 11. 28.