본문 바로가기

Programming

[Python] 백준 1074번 : Z def sol(n, r, c): global result if n == 2: if r == R and c == C: print(result) return result += 1 if r == R and c + 1 == C: print(result) return result += 1 if r + 1 == R and c == C: print(result) return result += 1 if r + 1 == R and c + 1 == C: print(result) return result += 1 return sol(n / 2, r, c) sol(n / 2, r, c + n / 2) sol(n / 2, r + n / 2, c) sol(n / 2, r + n / 2, c + n / 2) result = 0 N.. 더보기
[Python] 백준 2747번 : 피보나치 수 n = int(input()) a, b = 0, 1 while n > 0: a, b = b, a + b n -= 1 print(a) 더보기
[Python] 백준 10989번 : 수 정렬하기 3 import sys N = int(sys.stdin.readline()) num = [0 for _ in range(10001)] for _ in range(N): x = int(sys.stdin.readline()) num[x] += 1 for i in range(10001): if num[i] != 0: for k in range(num[i]): print(i) 더보기
[Python] 백준 11650번 : 좌표 정렬하기 n = int(input()) array = [] for _ in range(n): x, y = map(int, input().split(' ')) array. append((x, y)) array = sorted(array) for i in array: print(i[0], i[1]) 더보기
[Python] 백준 10814번 : 나이순 정렬 n = int(input()) arr = [] for _ in range(n): input_data = input().split(' ') arr.append((int(input_data[0]), input_data[1])) arr = sorted(arr, key=lambda x:x[0]) for i in arr: print(i[0], i[1]) 더보기
[Python] 백준 1427번 : 소트인사이드 arr = input() for i in range(9, -1, -1): for j in arr: if int(j) == i: print(i, end='') 더보기
[Python] 백준 2750번 : 수 정렬하기 n = int(input()) arr = [] for _ in range(n): arr.append(int(input())) arr.sort() for a in arr: print(a) 더보기
[Python] 백준 4195번 : 친구 네트워크 def find(x): if x == parent[x]: return x else: p = find(parent[x]) parent[x] = p return p def union(x, y): x = find(x) y = find(y) if x != y: parent[y] = x number[x] += number[y] test_case = int(input()) for _ in range(test_case): parent = dict() number = dict() f = int(input()) for _ in range(f): x, y = input().split(' ') if x not in parent: parent[x] = x number[x] = 1 if y not in parent: paren.. 더보기