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

문제 문제 링크 문제 접근 에라토스테네스의 체 알고리즘 사용 에라토스테네스 위키피디아 에라토스테네스의 체 - 위키백과, 우리 모두의 백과사전 ko.wikipedia.org 코드 import sys input = sys.stdin.readline m = int(input()) n = int(input()) # 에라토스테네스 알고리즘 dp = [True for _ in range(n+1)] for i in range(2, n+1): if dp[i]: j = 2 while i * j

문제 문제 링크 코드 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 n = int(input()) C = list(int(input()) for _ in range(n)) C.sort() result = 0 count = 0 while C: count += 1 x = C.pop() if count % 3 != 0: result += x print(result)

문제 문제 링크 코드 import sys input = sys.stdin.readline def tip(money, idx): return money - (idx - 1) n = int(input()) lst = list(int(input()) for _ in range(n)) lst.sort(reverse=True) result = 0 for i in range(n): t = tip(lst[i], i+1) if t >= 0: result += t print(result)