Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int f[100005];
- int main()
- {
- int n;
- cin >> n;
- n++;
- for (int i=2; i*i <= n; i++)
- {
- if (f[i] == 0)
- {
- for (int j=i*i; j <= n; j+=i) f[j]=1;
- }
- }
- if (n < 4)
- {
- cout << 1 << endl;
- }
- else
- {
- cout << 2 << endl;
- }
- for (int i=2; i <= n; i++) cout << f[i]+1 << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement