Advertisement
Guest User

Untitled

a guest
May 25th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,x[100003],ans=0,t,i,j,c;
  6. while(scanf("%d",&n)!=EOF){
  7. ans=0;
  8. for(i=2;i<=(n/2)+1;i++){
  9. t=1;
  10. for(j=i;j<=n;j*=2){
  11. t++;
  12. }
  13. if(ans<=t){ans=t;}
  14. }
  15.  
  16.  
  17. for(i=2;i<=n;i++){
  18. c=2;
  19. for(j=i;j<=n;j+=i){
  20. if(x[j]==0 && c==2){
  21. x[j]=c;c++;
  22. }
  23. else if(i<j){
  24. x[j]=c;
  25. }
  26. else{
  27. c=x[j];
  28. c++;
  29. }
  30.  
  31. // printf("%d %d\n",j,x[j]);
  32. }
  33.  
  34. }printf("%d\n1",ans);
  35. for(i=2;i<=n;i++){
  36. cout<<' '<<x[i];
  37. }
  38. printf("\n");
  39.  
  40.  
  41. }
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement