[백준 바킹독] 0x09 - BFS 토마토(7576)
Introduction
pass
https://www.acmicpc.net/problem/2609
a = 24
b = 18
r = a%b
while r != 0:
big = b
small = r
r = big%small
print(small)
>> 6
a = 24
b = 18
r = a%b
while r != 0:
big = b
small = r
r = big%small
print(int(a*b/small))
>> 72
import sys
input = sys.stdin.readline
num1, num2 = map(int,input().split())
def GCD(b, s):
big = b
small = s
r = big%small
while r!=0:
big = small
small = r
r = big%small
return small
if (num1>num2):
big = num1
small = num2
else:
big = num2
small = num1
gcd = GCD(big,small)
print(gcd)
print(int(big*small/gcd))
https://www.acmicpc.net/problem/1978
import sys
input = sys.stdin.readline
N = int(input())
numbers = list(map(int,input().split()))
lists = []
for n in range(2, 1001):
for i in range(2, n):
if n % i == 0:
break
else:
lists.append(n)
cnt = 0
for num in numbers:
if num in lists:
cnt += 1
print(cnt)
https://www.acmicpc.net/problem/6588
import sys
input = sys.stdin.readline
# 입력
numbers = []
N = int(input())
while N!=0:
numbers.append(N)
N = int(input())
# 소수 리스트 생성
lists = []
for n in range(3,max(numbers)):
for i in range(3,n):
if n%i == 0:
break
else:
lists.append(n)
# 계산
result = {}
for num in numbers:
# num 값에 맞는 소수 리스트 가져오기
dummy_list = []
if num != max(numbers):
cnt = 0
for i in range(len(lists)):
if lists[i]>num:
cnt=i
break
dummy_list = lists[:cnt]
else:
dummy_list = lists[:]
# num 값에 맞는 소수 리스트 출력
result[num] = [-1,-1]
findFlag = False
for big in range(len(dummy_list)-1,-1,-1):
for small in range(0,len(dummy_list)):
if num == dummy_list[big]+dummy_list[small]:
result[num] = [dummy_list[small],dummy_list[big]]
findFlag = True
break
elif num < dummy_list[big]+dummy_list[small]:
break
if findFlag == True:
break
# 출력
for num in numbers:
if result[num][0]!=-1 and result[num][1]!=-1:
print("{0} = {1} + {2}".format(num,result[num][0],result[num][1]))
else:
print("Goldbach's conjecture is wrong.")
에라토스테네스의 체는 N보다 작거나 같은 모든 소수를 찾는 유명한 알고리즘이다.
이 알고리즘은 다음과 같다.
import math
# 소수 판별 함수(에라토스테네스의 체)
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] ]
pass
N!에서 뒤에서부터 처음 0이 아닌 숫자가 나올 때까지 0의 개수를 구하는 프로그램을 작성하시오.
import sys
input = sys.stdin.readline
# 값 초기화
N = int(input())
if N == 0:
print(0)
else:
pactorial = 1
for i in range(1,N+1):
pactorial*=i
cnt = 0
s = str(pactorial)
for i in range(len(s)-1,-1,-1):
if s[i] != '0':
break
cnt += 1
print(cnt)
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...