목록Python/백준 (129)
가오리의 코딩일기
decimalNumber, xNumber = map(int, input().split()) result = '' pin = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" while decimalNumber != 0: result += str(pin[decimalNumber % xNumber]) decimalNumber //= xNumber print(result[::-1])
import math testCase = int(input()) for i in range(0, testCase): number1, number2 = map(int, input().split()) print(math.lcm(number1, number2))
n = int(input()) if n == 1: print('') for i in range(2, n+1): while n % i == 0: print(i) n /= i
binaryNumber = int(input(), 2) print(oct(binaryNumber)[2:])
e,s,m = map(int,input().split()) year = 1 while True: if (year - e) %15 == 0 and (year-s)%28== 0 and (year-m)%19==0: break year+=1 print(year)
→ 곱셈을 하는 경우: 0과 음수, 양수와 양수, 음수와 음수 → 덧셈을 하는 경우: 0과 양수, 양수와 음수, 1과 음수, 1과 양수 number = int(input()) positive = [] negative = [] result = 0 for _ in range(number): n = int(input()) if n == 1: result += 1 elif n > 1: positive.append(n) else: negative.append(n) positive.sort(reverse=True) negative.sort() if len(positive) % 2 == 0: for i in range(0, len(positive), 2): result += positive[i] * positive[..
def three_search(start, end): while abs(end - start) > 1e-9: mid1 = (2 * start + end) / 3 mid2 = (start + 2 * end) / 3 if distance(mid1) > distance(mid2): start = mid1 else: end = mid2 return distance(start) def distance(i): minX = ax * i + bx * (1 - i) minY = ay * i + by * (1 - i) kangX = cx * i + dx * (1 - i) kangY = cy * i + dy * (1 - i) return ((kangX - minX) ** 2 + (kangY - minY) ** 2) ** 0..