Advertisement
edutedu

17.09.2018 2

Sep 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. int n,c,a[50],cmmnp=0,i,b[50],j,k=0,l,d,p=0;
  2. cin>>n;
  3. for(i=0; i<n; i++)
  4. {
  5. cin>>a[i];
  6. }
  7. for(i=0; i<n; i++)
  8. {
  9. c=0;
  10. for(int j=1; j<=a[i]; j++)
  11. {
  12. if(a[i]%j==0)
  13. c++;
  14. }
  15. if(c==2 && a[i]>cmmnp)
  16. cmmnp=a[i];
  17.  
  18. }
  19. for(i=0; i<n; i++)
  20. {
  21. for(j=1; j<=a[i]; j++)
  22. {
  23. if(a[i]%j==0)
  24. {
  25. b[k]=j;
  26. k++;
  27. }
  28. }
  29.  
  30. for(i=0; i<k; i++)
  31. {
  32. d=0;
  33. for(int j=1; j<=b[i]; j++)
  34. {
  35. if(b[i]%j==0)
  36. d++;
  37. }
  38. if(d==2)
  39. p++;
  40. if(p==3)
  41. cout<<b[i];
  42. }
  43. }
  44. cout<<cmmnp<<endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement