Advertisement
a53

PMAX

a53
Feb 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. typedef int NrMare[10010];
  5.  
  6. int nr_ac_div(int n)
  7. {
  8. int d,p=0,x=1;
  9. if(n%2==0)
  10. {
  11. while(n%2==0)
  12. {
  13. p++;
  14. n=n/2;
  15. }
  16. x*=2;
  17. }
  18. d=3;
  19. while(n>1)
  20. {
  21. if(n%d==0)
  22. {
  23. p=0;
  24. while(n%d==0)
  25. {
  26. p++;
  27. n=n/d;
  28. }
  29. x*=d;
  30. }
  31. else
  32. d+=2;
  33. if(n>1&&d*d>n)
  34. {
  35. x*=n;
  36. break;
  37. }
  38. }
  39. return x;
  40. }
  41.  
  42. void AtribMic(NrMare x, int n)
  43. {
  44. x[0]=0;
  45. if(n==0)
  46. x[(x[0]=1)]=0;
  47. else
  48. for(;n;n/=10)
  49. x[++x[0]]=n%10;
  50. }
  51.  
  52. void ProdusMic(NrMare x, int n)
  53. //x <- x*n
  54. {
  55. int i,t=0;
  56. for(i=1;i<=x[0];i++,t/=10)
  57. {
  58. t+=x[i]*n;
  59. x[i]=t%10;
  60. }
  61. for(;t;t/=10)
  62. x[++x[0]]=t%10;
  63. }
  64.  
  65. void AfisareMare(NrMare x)
  66. {
  67. for(int i=x[0];i>=1;--i)
  68. cout<<x[i];
  69. }
  70.  
  71. int main()
  72. {
  73. int n,a;
  74. NrMare P;
  75. AtribMic(P,1);
  76. cin>>n;
  77. for(int i=1;i<=n;++i)
  78. cin>>a,ProdusMic(P,nr_ac_div(a));
  79. AfisareMare(P);
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement