본문 바로가기

백준1056

백준 2154 수 이어 쓰기 3 def sol(n): ans = '' for i in range(1, n + 1): ans += str(i) return(ans.find(str(n)) + 1) n=int(input()) print(sol(n)) https://www.acmicpc.net/problem/2154 2154번: 수 이어 쓰기 3 첫째 줄에 N(1 ≤ N ≤ 100,000)이 주어진다. www.acmicpc.net find 함수 쓰시면 쉽게 구현 가능합니다 If you use find() function , It will be easy peasy 2022. 10. 23.
백준 10205 헤라클레스와 히드라 def sol(n,s): for i in s: if i=='c': n+=1 elif i=='b': n-=1 if n==0: return 0 return n k=int(input()) for i in range(k): print("Data Set %d:"%(i+1)) n=int(input()) s=input() print(sol(n,s)) if i!=k-1: print() https://www.acmicpc.net/problem/10205 10205번: 헤라클레스와 히드라 헤라클레스는 그리스 신화의 유명한 비극적인 영웅이다. 그는 제우스의 사생아로 태어났는데, 이때문에 제우스의 아내 헤라는 그를 매우 싫어했다. 그는 매우 강한 힘과 높은 지식을 가졌지만, www.acmicpc.net 조건문과 간단한 문자열.. 2022. 10. 22.
백준 25640 MBTI mbti=input() n=int(input()) answer=0 for i in range(n): if input()==mbti: answer+=1 print(answer) https://www.acmicpc.net/problem/25640 25640번: MBTI 진호는 요즘 유행하는 심리 검사인 MBTI에 관심이 많다. MBTI는 아래와 같이 네 가지 척도로 사람들의 성격을 구분해서, 총 $16$가지의 유형중에서 자신의 유형을 찾을 수 있는 심리 검사이다. 내향( www.acmicpc.net 쉽죠 같은 문자열 카운팅하면 됩니다. Just count same String 2022. 10. 21.
백준 15000 CAPS s=input() print(s.upper()) https://www.acmicpc.net/problem/15000 15000번: CAPS Earth is under attack! Messages need to be sent to the Earth Defense Force (EDF) that makes clear that the situation is dire. The EDF’s strongest forces consist of mechs (huge bipedal robots) that are piloted by Japanese teenagers. To make sure that the www.acmicpc.net 문자열을 전부 대문자로 바꾸면 됩니다 All character should be conve.. 2022. 10. 21.
백준 25372 성택이의 은밀한 비밀번호 def sol(s): answer='no' if len(s)>=6 and len(s) 2022. 10. 20.
백준 1026 보물 https://www.acmicpc.net/problem/1026 1026번: 보물 첫째 줄에 N이 주어진다. 둘째 줄에는 A에 있는 N개의 수가 순서대로 주어지고, 셋째 줄에는 B에 있는 수가 순서대로 주어진다. N은 50보다 작거나 같은 자연수이고, A와 B의 각 원소는 100보다 작거 www.acmicpc.net def sol(nums1,nums2): answer=0 for i in range(len(nums1)): answer+=nums1[i]*nums2[i] return answer n=int(input()) nums1=sorted(list(map(int,input().split()))) nums2=sorted(list(map(int,input().split())), reverse=True) p.. 2022. 10. 19.
백준 2993 세 부분 def sol(s): len_s = len(s) strings = [] for i in range(1, len_s - 1): for j in range(1, len_s - 1): if i + j 2022. 10. 18.
백준 2535 아시아 정보올림피아드 https://www.acmicpc.net/problem/2535 2535번: 아시아 정보올림피아드 첫 번째 줄에는 대회참가 학생 수를 나타내는 N이 주어진다. 단, 3 ≤ N ≤ 100이다. 두 번째 줄부터 N개의 줄에는 각 줄마다 한 학생의 소속 국가 번호, 학생 번호, 그리고 성적이 하나의 빈칸을 사 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 def sol(n,nums): nums.sort(key=lambda x: x[2],reverse=True) nations=[0]*n cnt=0 for i in range(len(nums)): if cnt==3: break if nations[nums[i][0]]!=2: nations[nums[i][0]]+.. 2022. 10. 18.
백준 20124 모르고리즘 회장님 추천 받습니다 https://www.acmicpc.net/problem/20124 20124번: 모르고리즘 회장님 추천 받습니다 국렬이는 모르고리즘 차기 회장을 빠르게 구해야 한다. 안 그러면 대학원 가서도 회장을 해야 하기 때문이다. 그래서 국렬이는 어떻게든 2020년 연세대학교 프로그래밍 경진대회를 열어서 차기 www.acmicpc.net n=int(input()) nums=[] for i in range(n): name, score = input().split() nums.append([name,int(score)]) nums.sort(key=lambda x: (-x[1],x[0])) print(nums[0][0]) 리스트안에 있는 리스트를 정렬하면 되는데 하나는 오름차순, 하나는 내림차순으로 정렬해야할 경우 l.. 2022. 10. 17.
백준 23278 영화 평가 https://www.acmicpc.net/problem/23278 23278번: 영화 평가 스타트링크에는 영화 감상 동아리가 있다. 영화 동아리에는 총 N명의 구성원이 있고, 매주 모여서 영화 한 편을 본다. 영화를 본 뒤, 각 사람은 0보다 크거나 같고, 100보다 작거나 같은 정수로 영 www.acmicpc.net 1 2 3 4 n,l,h=map(int, input().split()) scores=sorted(list(map(int, input().split()))) ans=sum(scores[l:n-h])/(n-l-h) print(ans) Colored by Color Scripter cs 점수들이 최대 100이하고 숫자들 개수가 엄청 많았다면 계수정렬을 썼겠지만 그렇지 않으므로 내부함수를 사용해.. 2022. 10. 17.
백준 25496 장신구 명장 임스 https://www.acmicpc.net/problem/25496 25496번: 장신구 명장 임스 첫 번째 줄에 정수 $P$와 정수 $N$이 공백으로 구분되어 주어진다. ($1 \le P \le 200$, $1 \le N \le 1\,000$) 두 번째 줄에는 정수 $A_1, A_2, \dots, A_N$이 공백으로 구분되어 주어진다. ($1 \le A_i \le 200$) www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def sol(p,n,nums): nums.sort() answer = 0 for i in range(n): if p 2022. 10. 17.
백준 1251 단어 나누기 https://www.acmicpc.net/problem/1251 1251번: 단어 나누기 알파벳 소문자로 이루어진 단어를 가지고 아래와 같은 과정을 해 보려고 한다. 먼저 단어에서 임의의 두 부분을 골라서 단어를 쪼갠다. 즉, 주어진 단어를 세 개의 더 작은 단어로 나누는 것이다 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(s): len_s = len(s) strings = [] for i in range(1, len_s - 1): for j in range(1, len_s - 1): if i + j 2022. 10. 17.