Created
August 28, 2021 05:22
-
-
Save yeopgi/cf7f83ea132a254b88dd9e1d95b1a856 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| const int MAX = 1000000; | |
| bool check[MAX+1]; | |
| int main() { | |
| check[0] = check[1] = true; | |
| for (int i=2; i*i<=MAX; i++) { | |
| if (check[i] == false) { | |
| for (int j=i+i; j<=MAX; j+=i) { | |
| check[j] = true; | |
| } | |
| } | |
| } | |
| int m, n; | |
| cin >> m >> n; | |
| for (int i=m; i<=n; i++) { | |
| if (check[i] == false) { | |
| cout << i << '\n'; | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment