| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- appendleft
- deque
- LCM
- 소수찾기
- 백준
- 그리디 알고리즘
- Python
- 소수판별
- C#강의
- 합 구하기
- c#
- mvc
- 파이썬
- 완전탐색
- popleft
- 연관관계
- 누적합
- python3
- JPA
- unity
- 인프런
- BFS
- Java
- pypy3
- DP
- 우선순위큐
- 브루투포스
- 1일1솔
- 프로그래머스
- Today
- Total
목록전체 글 (139)
jae_coding
문제 문제 링크 문제 접근 소수를 탐색하는 함수를 구현한다. 소수라면 prime 리스트에 deque를 이용하여 추가시킨다. 소수가 존재하지 않는다면 -1을 출력한다. 만약 소수가 존재한다면 pop을 두번해서 최소 공배수를 구하는 공식 (x * y / 최대공약수)을 이용하여 소수의 리스트가 1이 될때까지 반복한다. 코드 import sys, math from collections import deque input = sys.stdin.readline def is_prime(num): if num == 1: return False if num % 2 == 0: if num == 2: return True return False for i in range(3, int(math.sqrt(num)) + 1): i..
문제 문제 링크 문제 접근. 배열 슬라이싱 사용하여 Input list 를 해결한다. itertools의 combination을 사용하여 중복을 허용하지 않는 조합을 만들어 낸다. math. gcd 사용하여 최대 공약수 도출한다. 코드 import sys, math from itertools import combinations input = sys.stdin.readline t = int(input()) for _ in range(t): input_list = list(map(int, input().split())) sum_gcd = 0 for i in combinations(input_list[1:], 2): a, b = i gcd = math.gcd(a, b) sum_gcd += gcd print(s..
문제 문제 링크 문제 접근 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))