Basic Math 2
Introduction
소수와 기하를 다뤄 봅시다.
Example
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
Please enable JavaScript to view the comments powered by Disqus.
2022
2 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
3 minute read
Introduction
1 minute read
Introduction
1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
2 minute read
Introduction
less than 1 minute read
Introduction
2 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
2 minute read
Introduction
1 minute read
Introduction
4 minute read
1167 트리의 지름
4 minute read
Introduction
1 minute read
Introduction
2 minute read
Introduction
less than 1 minute read
Introduction
4 minute read
Introduction
less than 1 minute read
Introduction
6 minute read
Introduction
2 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
3 minute read
Introduction
2 minute read
Introduction
2 minute read
Introduction
3 minute read
Introduction
less than 1 minute read
Git 명령어를 사용한 하위 디렉토리 다운로드
Clone 할 로컬 저장소 생성
1 minute read
Introduction
less than 1 minute read
# Fetch the submodule commits into the main repository
git remote add submodule_origin git://url/to/submodule/origin
git fetch submodule_origin
less than 1 minute read
Introduction
less than 1 minute read
Introduction
3 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
3 minute read
Introduction
less than 1 minute read
Introduction
4 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
2 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Spring Project
less than 1 minute read
the page for java
3 minute read
가벼운 Base image를 사용
less than 1 minute read
version: 3.0.0a10
less than 1 minute read
WIDTH
less than 1 minute read
version: 3.0.0a10
less than 1 minute read
#include <iostream>
#include <thread>
#include <chrono>
#include <mutex>
#include <atomic>
#include <string.h>
1 minute read
version: 3.0.0a10
less than 1 minute read
https://cplusplus.com/reference/future/
less than 1 minute read
Multithreading support was introduced in C++11.
less than 1 minute read
how to costom github blog using jekyll
less than 1 minute read
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...
Back to top ↑