일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
31 |
- 합 구하기
- 연관관계
- 그리디 알고리즘
- spring
- 브루투포스
- BFS
- pypy3
- appendleft
- deque
- Java
- JPA
- 1일1솔
- c#
- popleft
- 백준
- 완전탐색
- unity
- python3
- 누적합
- DP
- 인프런
- 소수판별
- LCM
- 소수찾기
- C#강의
- 파이썬
- 우선순위큐
- Python
- mvc
- 프로그래머스
- Today
- Total
목록python3 (8)
jae_coding

문제 문제 링크 문제 접근 math.gcd활용 ( 최대 공약수 ) 최대 공약수가 1이라면 그 두개의 수는 서로소 코드 import sys, math input = sys.stdin.readline # 서로소: 1을 제외한 나머지 공약수중 곂치는것이 없는 수 n = int(input()) a = list(map(int, input().split())) x = int(input()) result = list() for i in a: gcd = math.gcd(i, x) if gcd == 1: result.append(i) print(sum(result) / len(result))

문제 문제 링크 문제 접근 에라토스테네스의 체를 사용하기에는 n의 범위가 4 * 10^ 9이기 때문에 적합하지 않다. 그렇기 때문에 일반 prime number을 구하는 함수를 만들어 사용한다. 만든 함수에서 n보다 크거나 같은 수 중 프라임넘버를 찾고 break포인트를 걸어준다. 코드 import sys, math input = sys.stdin.readline def is_prime_number(number): if number

문제 문제 링크 문제 접근 while 루프 사용 index를 1씩 증가시키며 mod가 0인경우 출력해준다. 코드 import sys input = sys.stdin.readline n = int(input()) i = 2 while n != 1: if n % i == 0: n /= i print(i) i = 2 else: i += 1

문제 문제 링크 코드 import sys input = sys.stdin.readline input_string = list("A" + input().strip()) count = 0 min_result = "" max_result = "" # max_val for i in range(len(input_string)): c = input_string[i] if c == 'M': count += 1 if input_string[i-1] == 'M': min_result += "0" else: min_result += "1" elif c == 'K': min_result += "5" if count == 0: max_result += "5" else: max_result += str(5 * 10 ** cou..

문제 문제 링크 코드 import sys from collections import deque input = sys.stdin.readline n = int(input()) colors = deque(input().strip()) result_colors = list() primary_color = "" while colors: x = colors.popleft() if x != primary_color: result_colors.append(x) primary_color = x if result_colors.count('B') >= result_colors.count('R'): result = 1 + result_colors.count('R') else: result = 1 + result_colors..

문제 문제 링크 코드 import sys input = sys.stdin.readline n = int(input()) t = list(map(int, input().split())) t.sort() result = -1 if n % 2 == 0: for i in range(int(n / 2)): result = max(result, t[i] + t[len(t)-i-1]) else: result = max(result, t.pop()) for i in range(int(n / 2)): result = max(result, t[i] + t[len(t)-i-1]) print(result)

문제 문제 링크 코드 import sys input = sys.stdin.readline n = int(input()) energy_drinks = list(map(int, input().split())) energy_drinks.sort() result = energy_drinks[n-1] for i in range(n-1): result += energy_drinks[i] / 2 print(result)

문제 문제 링크 코드 import sys input = sys.stdin.readline input_string = list(input().strip()) stack = list() ans = 0 count = 1 primary_value = 0 for i in input_string: if i == '(': count *= 2 stack.append(i) elif i == '[': count *= 3 stack.append(i) elif i == ')': # 올바른 괄호열이 아닐 경우 if not stack or stack[-1] == '[': ans = 0 break elif primary_value == '(': ans += count count //= 2 stack.pop() elif i == '..