Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- typedef int NrMare[10010];
- int nr_ac_div(int n)
- {
- int d,p=0,x=1;
- if(n%2==0)
- {
- while(n%2==0)
- {
- p++;
- n=n/2;
- }
- x*=2;
- }
- d=3;
- while(n>1)
- {
- if(n%d==0)
- {
- p=0;
- while(n%d==0)
- {
- p++;
- n=n/d;
- }
- x*=d;
- }
- else
- d+=2;
- if(n>1&&d*d>n)
- {
- x*=n;
- break;
- }
- }
- return x;
- }
- void AtribMic(NrMare x, int n)
- {
- x[0]=0;
- if(n==0)
- x[(x[0]=1)]=0;
- else
- for(;n;n/=10)
- x[++x[0]]=n%10;
- }
- void ProdusMic(NrMare x, int n)
- //x <- x*n
- {
- int i,t=0;
- for(i=1;i<=x[0];i++,t/=10)
- {
- t+=x[i]*n;
- x[i]=t%10;
- }
- for(;t;t/=10)
- x[++x[0]]=t%10;
- }
- void AfisareMare(NrMare x)
- {
- for(int i=x[0];i>=1;--i)
- cout<<x[i];
- }
- int main()
- {
- int n,a;
- NrMare P;
- AtribMic(P,1);
- cin>>n;
- for(int i=1;i<=n;++i)
- cin>>a,ProdusMic(P,nr_ac_div(a));
- AfisareMare(P);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement