본문 바로가기

파이썬2319

[백준/파이썬] 10203번 Count Vowels -Codevowels = "aeiou"for _ in range(int(input())): line = input() res = 0 for v in vowels: res += line.count(v) print(f"The number of vowels in {line} is {res}.") 2025. 6. 25.
[백준/파이썬] 24509번 상품의 주인은? -Codefrom sys import stdininput = stdin.readlinen = int(input())student_score = [ list(map(int, input().split())) for _ in range(n)]award = []result = []for sub in range(1, 5): # 정렬 not_award = [s for s in student_score if s[0] not in award] not_award.sort(key=lambda x: (-x[sub], x[0])) # 최고 득점자 가져옴 win = not_award[0][0] result.append(win) award.append(win)print(*result) 2025. 6. 24.
[백준/파이썬] 4927번 Casting Out Nines -Codedef nums_sum(nums): return sum(int(num) for num in nums)t = 0while True: line = input() if line == ".": break t += 1 line = line[:-1] if "*" in line: a_str, temp = line.split("*") cal = "*" else: a_str, temp = line.split("+") cal = "+" b_str, c_str = temp.split("=") a = nums_sum(a_str) % 9 b = nums_sum(b_str) % 9 c = nums_s.. 2025. 6. 23.
[백준/파이썬] 23278번 영화 평가 -Coden, l, h = map(int, input().split())score = sorted(list(map(int, input().split())))print(sum(score[l:n - h]) / (n - l - h)) 2025. 6. 22.
[백준/파이썬] 5364번 Escape Route -Codefrom math import sqrtn = int(input())now_x, now_y = map(int, input().split())rex_x, res_y = -1, -1min_dist = 1e9for _ in range(n - 1): x, y = map(int, input().split()) # 거리 계산 dist = round(sqrt((now_x - x) ** 2 + (now_y - y) ** 2), 2) # 현재 저장한 거리보다 작은 경우 if min_dist > dist: rex_x, res_y = x, y min_dist = dist# 출력print(now_x, now_y)print(rex_x, res_y)print(min_di.. 2025. 6. 21.
[백준/파이썬] 32762번 더치 페이 -Codefrom sys import stdininput = stdin.readlinen, m = map(int, input().split())for _ in range(n): s, t = map(int, input().split())total = 0for _ in range(m): t, p = map(int, input().split()) total += pprint(f"{total / n:.4f}") 2025. 6. 20.