본문 바로가기

파이썬2193

[백준/파이썬] 26676번 Wybór zadań -Codedef solution(n, words): arr = { 1: [0, 0, 0], 2: [0, 0, 0], 3: [0, 0, 0], 4: [0, 0, 0], 5: [0, 0, 0] } for w in words: num, word = int(w[0]), ord(w[1]) - ord('A') arr[num][word] += 1 for el in arr: cut = 1 if el != 5 else 2 for i in range(3): if arr[el][i] 2024. 6. 11.
[백준/파이썬] 31663번 Mean Words -Coden = int(input())cnts, sums = [0] * 46, [0] * 46for _ in range(n): s = input() for i in range(len(s)): sums[i] += ord(s[i]) cnts[i] += 1res = ""for i in range(46): if cnts[i] == 0: break res += chr(sums[i] // cnts[i])print(res) 2024. 6. 10.
[백준/파이썬] 8574번 Ratownik -Codefrom math import sqrtfrom sys import stdininput = stdin.readlineres = 0n, k, x, y = map(int, input().split())for _ in range(n): xi, yi = map(int, input().split()) if sqrt((xi - x) ** 2 + (yi - y) ** 2) > k: res += 1print(res) 2024. 6. 9.
[백준/파이썬] 14911번 궁합 쌍 찾기 -Codefrom itertools import combinationsnums = sorted(list(map(int, input().split())))n = int(input())res = []for com in combinations(nums, 2): if sum(com) == n and com not in res: res.append(com) print(*com)print(len(res)) 2024. 6. 8.
[백준/파이썬] 9358번 순열 접기 게임 -Codefrom collections import dequefor t in range(1, int(input()) + 1): n = int(input()) nums = deque(list(map(int, input().split()))) while len(nums) != 2: temp = deque() while nums: front = nums.popleft() if nums: back = nums.pop() temp.append(front + back) else: temp.append(front * 2) nu.. 2024. 6. 7.
[백준/파이썬] 30315번 King's Keep -Codefrom math import sqrtres = 1e9t = int(input())arr = [list(map(int, input().split())) for _ in range(t)]for i in range(t): x, y = arr[i][0], arr[i][1] temp = 0 for j in range(t): if i == j: continue x2, y2 = arr[j][0], arr[j][1] temp += sqrt((x - x2) ** 2 + (y - y2) ** 2) temp /= (t - 1) res = min(res, temp)print(res) 2024. 6. 6.