전체 글 206

파이썬 백준 2261 가장 가까운 두 점

import sys input = sys.stdin.readline l = [] n = int(input()) for i in range(n) : l.append(list(map(int, input().split()))) l.sort() def length(p, q) : return (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2 def DAC(start, end) : if end == start + 1 : return length(l[start], l[end]) center = (start + end) // 2 minl = min(DAC(start, center), DAC(center, end)) rng = [] for i in range(start, end + 1) : if (..

파이썬 백준 1629 곱셈

a, b, c = map(int, input().split()) bilist = [0 for i in range(31)] for i in range(30, -1, -1) : bilist[i] = b // pow(2, i) b = b - bilist[i] * pow(2, i) powerlist = [0 for i in range(31)] powerlist[0] = a % c for i in range(1, 31) : powerlist[i] = pow(powerlist[i-1], 2) % c remain = 1 for i in range(31) : if bilist[i] == 1 : remain = (remain * powerlist[i]) % c print(remain) 2^32 이하의 모든 자연수는 32..