https://school.programmers.co.kr/learn/courses/30/lessons/12979코드function solution(n, stations, w) { let answer = 0; stations.unshift(-w); stations.push(n + w + 1); for (let i = 0; i w * 2) { answer += Math.ceil((gap - w * 2) / (w * 2 + 1)); } } return answer;} 두 기지국의 사이(`gap`)가 w*2보다 크다면 그 사이에 추가로 기지국을 세워야 한다. 이 때 필요한 기지국의 개수는 커버되지 않는 범위의 길이인 `gap-w*2`를 하나의 기지국이 커버할 수 있는 길이인 `w*2..
문제풀이/수학
https://school.programmers.co.kr/learn/courses/30/lessons/12985코드function solution(n,a,b){ if(a>b){ const temp = a a = b b = temp } let answer = 1; for(let i=0;i 번호가 n이었다면 다음 라운드로 넘어갔을 때의 번호는 n/2를 소수점 첫째자리에서 올림한 값과 같다는 사실만 알면 어렵지 않게 풀 수 있는 문제였다. a와 b의 다음 라운드 번호가 같아지는 순간을 구하면 그때가 둘이 맞붙는 라운드이다.

https://www.acmicpc.net/problem/1002코드from math import sqrtfor _ in range(int(input())): x1, y1, r1, x2, y2, r2 = map(int, input().split()) dist = sqrt((x1-x2)**2+(y1-y2)**2) if dist == 0: print(0 if r1 != r2 else -1) elif dist 처음 봤을 때는 너무 쉽다고 생각했는데, 틀렸다....다시 곰곰히 생각해보니 생각 못해준 조건들이 많았다. 처음에는 각 원의 중심이 다른 원의 영역 내에 포함되지 않는 경우만 고려했던 것이 잘못됐다. 그래서 어떤 경우가 있을 수 있는지 구해봤다. 여기서 `dist`는 ..
https://www.acmicpc.net/problem/1241코드import sysfrom collections import defaultdictinput = sys.stdin.readlinen = int(input())students = []num_cnt = defaultdict(int)for _ in range(n): input_value = int(input()) students.append(input_value) num_cnt[input_value] += 1maximum_value = max(students)count = [0]*(maximum_value+1)for k, v in sorted(num_cnt.items()): count[k] += v-1 for i in..
https://www.acmicpc.net/problem/1016코드from math import sqrt, floormin_val, max_val = map(int, input().split())length = max_val-min_val+1non_square = [True]*lengthfor i in range(2, floor(sqrt(max_val))+1): square_num = i**2 if min_val % square_num == 0: start = (min_val//square_num)*square_num else: start = (min_val//square_num+1)*square_num for j in range(start, min_val..