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 | #include<cstdio> bool arr[246914]; int main(void) { int n,cnt; arr[1]=true; for (int i = 2; i*i <= 246912; i++) if (arr[i] == false) for (int j = i * i; j <= 246912; j += i) arr[j] = true; while(scanf("%d", &n)==1) { if (n==0) break; else { cnt=0; for (int i=n+1; i<=2*n; i++) if(arr[i]==false) cnt++; printf("%d\n", cnt); } } return 0; } | cs |
'백준 1 > 수학' 카테고리의 다른 글
| [백준 15953] 상금 헌터 (0) | 2020.12.05 |
|---|---|
| [백준 2750] 수 정렬하기 (0) | 2020.12.05 |
| [백준 1929] 소수 구하기 (0) | 2020.12.05 |
| [백준 10867] 중복 빼고 정렬하기 (0) | 2020.12.05 |
| [백준 11004] k번째 수 (0) | 2020.12.05 |