본문 바로가기

백준1056

백준 14405 피카츄 https://www.acmicpc.net/problem/14405 14405번: 피카츄 피카츄는 "pi", "ka", "chu"를 발음할 수 있다. 따라서, 피카츄는 이 세 음절을 합친 단어만 발음할 수 있다. 예를 들면, "pikapi"와 "pikachu"가 있다. 문자열 S가 주어졌을 때, 피카츄가 발음할 수 있는 문 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def sol(s): pikachu = ['pi', 'ka', 'chu'] for i in pikachu: s = s.replace(i, '*'*len(i)) if len(s)==s.count('*'): return True else: return False s=input() if sol(s) == Tr.. 2022. 10. 31.
백준 2033 반올림 https://www.acmicpc.net/problem/2033 2033번: 반올림 정수 N이 주어져 있을 때 이 수가 10보다 크면 일의 자리에서 반올림을 하고, 이 결과가 100보다 크면 다시 10의 자리에서 반올림을 하고, 또 이 수가 1000보다 크면 100의 자리에서 반올림을 하고.. ( www.acmicpc.net 1 2 3 4 5 6 7 n=int(input()) for i in range(1,10): if n>10**i: n=int(round(n+0.0001,-i)) else: break print(n) cs 어려운 문제는 아닌데 알아야 할 게 2가진데요 Not hard problem, but you should know 2 Ways round 는 round(숫자, 위치) 개념이고 rou.. 2022. 10. 31.
백준 2526 싸이클 https://www.acmicpc.net/problem/2526 2526번: 싸이클 두 자연수 N과 P를 가지고 다음 과정을 거쳐서 나오는 수를 차례대로 출력해보자. 처음 출력하는 수는 N이고, 두 번째 이후 출력하는 수는 N을 곱하고 P로 나눈 나머지를 구하는 과정을 반복하여 www.acmicpc.net 1 2 3 4 5 6 7 8 n, p = map(int, input().split()) nums=[n] while 1: if (nums[-1]*n)%p not in nums: nums.append((nums[-1]*n)%p) else: print(len(nums)-(nums.index((nums[-1]*n)%p))) break Colored by Color Scripter cs 반복문 입니다 nums.. 2022. 10. 31.
백준 25314 코딩은 체육과목 입니다 https://www.acmicpc.net/problem/25314 25314번: 코딩은 체육과목 입니다 오늘은 혜아의 면접 날이다. 면접 준비를 열심히 해서 앞선 질문들을 잘 대답한 혜아는 이제 마지막으로 칠판에 직접 코딩하는 문제를 받았다. 혜아가 받은 문제는 두 수를 더하는 문제였다. C++ www.acmicpc.net 1 2 3 4 pyfrom math import ceil n=int(input()) print('long '*ceil(n/4)+'int') cs 2022. 10. 30.
백준 12606 Reverse Words (Large) n=int(input()) for i in range(1,n+1): s = input() print("Case #%d: "%(i),end='') print(*s.split()[::-1]) https://www.acmicpc.net/problem/12606 12606번: Reverse Words (Large) Given a list of space separated words, reverse the order of the words. Each line of text contains L letters and W words. A line will only consist of letters and space characters. There will be exactly one space character betw.. 2022. 10. 30.
백준 13322 접두사 배열 # def sol(s): # prefix=[[s[:i+1],i] for i in range(len(s))] # prefix.sort(key= lambda x: x[0]) # for i in prefix: # print(i[1]) # s=input() for i in range(len(s)): print(i) https://www.acmicpc.net/problem/13322 13322번: 접두사 배열 접미사 배열(suffix array)이란, 어떤 문자열의 모든 접미사를 사전 순으로 정렬한 뒤, 각 접미사의 시작 위치를 기록한 배열을 의미한다. 예를 들어 'banana' 라는 문자열에 대해 접미사 배열을 구한 www.acmicpc.net 주석 부분이 실제 접두사 배열 구현내역인데 생각해보니 필요없네요 ^.. 2022. 10. 29.
백준 9455 박스 https://www.acmicpc.net/problem/9455 9455번: 박스 첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스의 첫째 줄에는 m과 n이 주어진다. (1 ≤ m, n ≤ 100) 다음 m개 줄에는 그리드의 각 행의 정보를 나타내는 n개의 정수가 주어진다. 그 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 t=int(input()) for _ in range(t): m,n=map(int,input().split()) matrix=[list(map(int, input().split())) for i in range(m)] transposed_matrix=list(zip(*matrix)) sum_distance_box=0 for i in trans.. 2022. 10. 29.
백준 2456 나는 학급회장이다 https://www.acmicpc.net/problem/2456 2456번: 나는 학급회장이다 첫째 줄에는 반의 학생들의 수 N (3 ≤ N ≤ 1,000)이 주어진다. 다음 N개의 각 줄에는 각 학생이 제출한 회장후보 3명에 대한 선호 점수가 주어지는 데, 첫 번째 점수는 후보 1번에 대한 점수이고 두 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 first,second,third=[],[],[] n=int(input()) for i in range(n): a,b,c=map(int, input().split()) first.append(a) second.append(b) third.append(c) first = [sum(first), firs.. 2022. 10. 29.
백준 4641 Doubles https://www.acmicpc.net/problem/4641 4641번: Doubles 2~15개의 서로 다른 자연수로 이루어진 리스트가 있을 때, 이들 중 리스트 안에 자신의 정확히 2배인 수가 있는 수의 개수를 구하여라. 예를 들어, 리스트가 "1 4 3 2 9 7 18 22"라면 2가 1의 2배, 4가 2의 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 def sol(nums): answer=-1 for i in nums: if i*2 in nums: answer+=1 return answer while 1: nums=list(map(int, input().split())) if nums==[-1]: break else: print(sol(nums)) cs 자기 .. 2022. 10. 29.
백준 13235 팰린드롬 def sol(s): if s.lower() == s[::-1].lower(): return 'true' else: return 'false' s = input() print(sol(s)) https://www.acmicpc.net/problem/13235 13235번: 팰린드롬 팰린드롬은 앞에서부터 읽을 때와 뒤에서부터 읽을 때가 똑같은 단어를 의미한다. 예를 들어, eve, eevee는 팰린드롬이고, eeve는 팰린드롬이 아니다. 단어가 주어졌을 때, 팰린드롬인지 아닌지 판 www.acmicpc.net 아래 이전 문제와 같은 내용 Same logic with above link(My blog) https://sunchol21.tistory.com/1114 2022. 10. 28.
백준 14696 딱지놀이 https://www.acmicpc.net/problem/14696 14696번: 딱지놀이 표준 입력으로 다음 정보가 주어진다. 첫 번째 줄에는 딱지놀이의 총 라운드 수를 나타내는 자연수 N이 주어진다. N 은 1 이상 1,000 이하이다. 다음 줄에는 라운드 1에서 어린이 A가 내는 딱지에 나 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 def sol(a_nums,b_nums): a_len, a_nums = a_nums[0], a_nums[1:] b_len, b_nums = b_nums[0], b_nums[1:] a_nums.sort(reverse=True) b_nums.sort(reverse=T.. 2022. 10. 28.
백준 2947 나무 조각 https://www.acmicpc.net/problem/2947 2947번: 나무 조각 첫째 줄에 조각에 쓰여 있는 수가 순서대로 주어진다. 숫자는 1보다 크거나 같고, 5보다 작거나 같으며, 중복되지 않는다. 처음 순서는 1, 2, 3, 4, 5가 아니다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 nums=list(map(int, input().split())) answer=[1,2,3,4,5] def change(nums, start, end): if nums[start]> nums[end]: nums[start], nums[end] = nums[end], nums[start] print(*nums) return nums while nums!=answer: for.. 2022. 10. 28.