Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- vector<int> ans;
- for(int i = 0; i < n; ++i)
- {
- int a;
- cin >> a;
- bool flag = false;
- for(int i = 2; i <= sqrt(a); ++i)
- {
- if(a % i == 0)
- {
- flag = true;
- break;
- }
- }
- if (flag || a == 1)
- {
- ans.push_back(a);
- }
- }
- for(int i = 0; i < ans.size(); ++i)
- {
- cout << ans[i] << ' ';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement