![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/CiN0g/btsoRDNtzEc/vtTYJD3EQK4ugEtYK1G0xK/img.png)
문제 링크 17103번: 골드바흐 파티션 첫째 줄에 테스트 케이스의 개수 T (1 ≤ T ≤ 100)가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 정수 N은 짝수이고, 2 < N ≤ 1,000,000을 만족한다. www.acmicpc.net 문제 풀이 from sys import stdin input = stdin.readline primes = [True for _ in range(1000001)] for i in range(2, 1000001): if primes[i] == True: for j in range(i*2, 1000001, i): primes[j] = False T = int(input()) for i in range(T): n = int(input()) partition =..
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/cqZ0V0/btsnF3UcP7k/O8cX8qbotpZGYRg2U2CTt1/img.png)
문제 링크 7785번: 회사에 있는 사람 첫째 줄에 로그에 기록된 출입 기록의 수 n이 주어진다. (2 ≤ n ≤ 106) 다음 n개의 줄에는 출입 기록이 순서대로 주어지며, 각 사람의 이름이 주어지고 "enter"나 "leave"가 주어진다. "enter"인 경우는 www.acmicpc.net 문제 풀이 import sys n = int(sys.stdin.readline()) attendance = {} for i in range(n): name, status = sys.stdin.readline().split() if status == "enter": attendance[name] = 1 else: del attendance[name] print(*sorted(attendance.keys(), rev..
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/dsEJR8/btsnyfzZJJm/9QFGzz3DDgWGSpwFbC5POK/img.png)
문제 링크 4134번: 다음 소수 첫째 줄에 테스트 케이스의 개수가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 정수 n이 주어진다. www.acmicpc.net 문제 풀이 from sys import stdin input = stdin.readline test_case = int(input()) for i in range(test_case): n = int(input()) while 1: if n == 0 or n == 1: print(2) break for i in range(2, int(n ** 0.5) + 1 ): if n % i == 0: break else: print(n) break n += 1 *key point: 2부터 n의 제곱근까지의 수들로 나누어보며 약수가 있는지 확인한다..
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/GzBZy/btsnwYMf8sc/kKr5kSL1IIiIxdoxG13kdK/img.png)
문제 링크 2485번: 가로수 첫째 줄에는 이미 심어져 있는 가로수의 수를 나타내는 하나의 정수 N이 주어진다(3 ≤ N ≤ 100,000). 둘째 줄부터 N개의 줄에는 각 줄마다 심어져 있는 가로수의 위치가 양의 정수로 주어지며, 가 www.acmicpc.net 문제 풀이 from sys import stdin from math import gcd input = stdin.readline n = int(input()) location = [int(input()) for _ in range(n)] length = [location[i + 1] - location[i] for i in range(len(location) - 1)] g = gcd(*length) print(sum([len // g - 1 f..
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/K2VSa/btsnvJCwmoZ/QDeImKqvsq2G8H3QuRtJf1/img.png)
문제 링크 1735번: 분수 합 첫째 줄과 둘째 줄에, 각 분수의 분자와 분모를 뜻하는 두 개의 자연수가 순서대로 주어진다. 입력되는 네 자연수는 모두 30,000 이하이다. www.acmicpc.net 문제 풀이 a, b = map(int, input().split()) c, d = map(int, input().split()) e = a * d + b * c f = b * d def gcd(e, f): while f: mod = f f = e % f e = mod return e print(e//gcd(e, f), f//gcd(e, f)) *key point: 분수를 통분해서 더한 뒤 최대공약수로 약분한다.
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/bLn2ab/btsnxk2M41h/phAh1XKnyQGaNe3SEq6Dgk/img.png)
문제 링크 13241번: 최소공배수 정수 B에 0보다 큰 정수인 N을 곱해 정수 A를 만들 수 있다면, A는 B의 배수이다. 예: 10은 5의 배수이다 (5*2 = 10) 10은 10의 배수이다(10*1 = 10) 6은 1의 배수이다(1*6 = 6) 20은 1, 2, 4,5,10,20의 배수이다. 다 www.acmicpc.net 문제 풀이 a, b = map(int, input().split()) def gcd(a, b): while b: mod = b b = a % b a = mod return a print(a*b//gcd(a, b)) *key point: 유클리드 호제법으로 최대공약수를 구하고 최대공약수로 최소 공배수를 구한다.
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/bHgPdF/btsnvoyt6Xl/aflOQ6TG4a7zxBOR26cT7K/img.png)
문제 링크 14215번: 세 막대 첫째 줄에 a, b, c (1 ≤ a, b, c ≤ 100)가 주어진다. www.acmicpc.net 문제 풀이 length = sorted(list(map(int, input().split()))) if length[0] + length[1] > length[2]: print(sum(length)) else: print(sum(length) + (length[0] + length[1] - length[2] - 1)) *key point: 짧은 두 변의 합이 긴 변 보다 작은 경우 줄여야 하는 긴 변의 길이를 고려해준다.
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/bjJtjr/btsnvwXLGLs/a15PMdnbGTuHd1rNnaIpm0/img.png)
문제 링크 5073번: 삼각형과 세 변 각 입력에 맞는 결과 (Equilateral, Isosceles, Scalene, Invalid) 를 출력하시오. www.acmicpc.net 문제 풀이 while 1: a, b, c = map(int, input().split()) if a == 0 and b == 0 and c == 0: break list = sorted([a, b, c], reverse=True) if list[0] < list[1] + list[2]: if a == b == c: print("Equilateral") elif a == b or b == c or a == c: print("Isosceles") else: print("Scalene") else: print("Invalid") ..
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/moR9H/btsnxC3h9An/GY5CHcYWXKttaGFwxZpJxK/img.png)
문제 링크 24313번: 알고리즘 수업 - 점근적 표기 1 f(n) = 7n + 7, g(n) = n, c = 8, n0 = 1이다. f(1) = 14, c × g(1) = 8이므로 O(n) 정의를 만족하지 못한다. www.acmicpc.net 문제 풀이 a1, a2 = map(int, input().split()) c = int(input()) n0 = int(input()) if a1 * n0 + a2
문제 링크 24262번: 알고리즘 수업 - 알고리즘의 수행 시간 1 오늘도 서준이는 알고리즘의 수행시간 수업 조교를 하고 있다. 아빠가 수업한 내용을 학생들이 잘 이해했는지 문제를 통해서 확인해보자. 입력의 크기 n이 주어지면 MenOfPassion 알고리즘 수행 시 www.acmicpc.net 24263번: 알고리즘 수업 - 알고리즘의 수행 시간 2 오늘도 서준이는 알고리즘의 수행시간 수업 조교를 하고 있다. 아빠가 수업한 내용을 학생들이 잘 이해했는지 문제를 통해서 확인해보자. 입력의 크기 n이 주어지면 MenOfPassion 알고리즘 수행 시 www.acmicpc.net 24264번: 알고리즘 수업 - 알고리즘의 수행 시간 3 오늘도 서준이는 알고리즘의 수행시간 수업 조교를 하고 있다. 아빠가 수업..
- Total
- Today
- Yesterday
- 백준
- 25501
- 24060
- 24723
- Programmers
- 10807
- SQL
- 24313
- 4134
- 1269
- 2587
- 13241
- 코육대
- 2738
- 항해 플러스
- Wil
- 26069
- til
- 항해+
- 2053
- 5597
- 20920
- 벡준
- MySQL
- 17103
- Python
- 13909
- programmer
- 25192
- 2903
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |