Notice
Recent Posts
Recent Comments
Link
250x250
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- GPU #jtorch GPU #파이토치 병렬 #파이토치 GPU #pytorch gpu #multi process torch #horovod
- 구름자연어처리과정
- GPU #cuda out of memory #gpu 메모리 #pytorch
- 트랜스포머 #transformer #attention #self-attention #어텐션 #인공지능 #AI #딥러닝 #NLP #자연어처리
- cuda #centos #cuda삭제 #리눅스 #cenos cuda삭제
- 백준
- logistic regression
- docker #도커 #도커 컨테이너 #docker container #도커 우분투
- 깃허브 #우분투 #ubuntu #Github #깃허브 우분투 #깃헙 우분투 #깃헙
- jupyter notebook #anaconda #vscode #pytorch #딥러닝 #deep learning #vscode server #서버 vscode #ssh vscode #vscode cuda
- docker #cuda #docker container #도커 #도커 컨테이너 #쿠다 #cuda 11.3
- 파이썬 #Python
- Machine Learning
- pandas #folium #groupby #네이버부스트코스 #코칭스터디
- pytorch #cuda #우분투 torch #ubuntu pytorch #cuda torch #cuda pytorch
- docker #아나콘다 #anaconda #ubuntu anaconda #docker anaconda
- BERT #구글BERT #BERT의정석
- 알고리즘 #levenshtein distance #편집거리 #edit distance
- 트랜스포머 #자연어처리 #딥러닝 #구글 #attention #self-attention #BERT #transformer #deeplearing
- 구름
- 머신러닝
- 백준 #알고리즘 #골드
- ssh #우분투 ssh #우분터 서버 #도커 #우분투 도커 #docker #cuda #우분투 개발환경 #딥러닝 #ubuntu docker #ubuntu cuda
- docker #우분투 #ubuntu #도커 설치 #docker 설치 #docker installation #우분투 도커
Archives
- Today
- Total
바닥부터 시작하는 개발 공부
[알고리즘]백준 4134: 다음소수 본문
728x90
문제
정수 n(0 ≤ n ≤ 4*109)가 주어졌을 때, n보다 크거나 같은 소수 중 가장 작은 소수 찾는 프로그램을 작성하시오.
입력
첫째 줄에 테스트 케이스의 개수가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 정수 n이 주어진다.
출력
각각의 테스트 케이스에 대해서 n보다 크거나 같은 소수 중 가장 작은 소수를 한 줄에 하나씩 출력한다.
import sys
import math
N = int(sys.stdin.readline().strip())
def is_prime(n):
for i in range(2,int(math.sqrt(n))+1 ):
if n%i ==0:
return False
return True
for i in range(N):
num = int(sys.stdin.readline().strip())
if num ==0 or num ==1:
print(2)
else:
while True:
if is_prime(num)==True:
print(num)
break
num+=1728x90
'Algorithm > 알고리즘' 카테고리의 다른 글
| [알고리즘]백준 2960: 에라토스테네스의 체 (0) | 2023.03.03 |
|---|---|
| [알고리즘]백준 10830: 행렬 제곱 (0) | 2023.02.28 |
| [알고리즘]알고리즘의 복잡도와 설계 ti (0) | 2023.02.05 |
Comments