[백준 바킹독] 0x09 - BFS 토마토(7576)
Introduction
소수와 기하를 다뤄 봅시다.
https://www.acmicpc.net/step/8
2부터 X-1까지 모두 나눠서 X가 소수인지 판별하는 문제 2
주의) 안 될때는 부등호 범위가 틀렸는지 확인해보자
import sys
input = sys.stdin.readline
N = int(input())
M = int(input())
lists = []
for n in range(2, M+1):
for i in range(2, n):
if n%i == 0:
break
else:
lists.append(n)
result = []
for i in range(len(lists)):
if N <= lists[i]:
result = lists[i:]
break
if result:
print(sum(result))
print(result[0])
else:
print(-1)
N을 소인수분해하는 문제
더 빠르게 소수를 판별하는 문제
import sys
import math
input = sys.stdin.readline
N, M = map(int,input().split())
lists = []
def is_prime_number(n):
# 2부터 n까지의 모든 수에 대하여 소수 판별
array = [True for i in range(n+1)] # 처음엔 모든 수가 소수(True)인 것으로 초기화(0과 1은 제외)
# 에라토스테네스의 체
for i in range(2, int(math.sqrt(n)) + 1): #2부터 n의 제곱근까지의 모든 수를 확인하며
if array[i] == True: # i가 소수인 경우(남은 수인 경우)
# i를 제외한 i의 모든 배수를 지우기
j = 2
while i * j <= n:
array[i * j] = False
j += 1
return [ i for i in range(2, n+1) if array[i] ]
lists = is_prime_number(M)
result = []
for i in range(len(lists)):
if N <= lists[i]:
result = lists[i:]
break
for r in result:
print(r)
소수 응용 문제 1
소수 응용 문제 2
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
1167 트리의 지름
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Git 명령어를 사용한 하위 디렉토리 다운로드 Clone 할 로컬 저장소 생성
Introduction
# Fetch the submodule commits into the main repository git remote add submodule_origin git://url/to/submodule/origin git fetch submodule_origin
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Graph
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Introduction
Spring Project
the page for java
가벼운 Base image를 사용
version: 3.0.0a10
WIDTH
version: 3.0.0a10
#include <iostream> #include <thread> #include <chrono> #include <mutex> #include <atomic> #include <string.h>
version: 3.0.0a10
https://cplusplus.com/reference/future/
Multithreading support was introduced in C++11.
how to costom github blog using jekyll
You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different wa...