SHARE
TWEET

Untitled

a guest Jun 3rd, 2019 1,312 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int ans[100005];
  4. int main()
  5. {
  6.     int n,c=0;
  7.     scanf("%d",&n);
  8.     for (int i=2;i<=n;i++)
  9.     {
  10.         if (!ans[i])
  11.         {
  12.             ans[i]=++c;
  13.             for (int j=i;j<=n;j+=i)
  14.             ans[j]=ans[i];
  15.         }
  16.         printf("%d ",ans[i]);
  17.     }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top