Advertisement
nicuvlad76

Untitled

Dec 3rd, 2020
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #define N 1005
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int x,d,p,fmax=0,pmax=0;
  8.     int n,i;
  9.     cin>>n;
  10.     for(i=1;i<=n;i++)
  11.     {
  12.         cin>>x;///fiecare numar
  13.         ///descompun  x;
  14.         d=2;
  15.         while(x!=1)
  16.         {
  17.             p=0;
  18.             while(x%d==0){x/=d; p++;}
  19.             if(p!=0)
  20.             {
  21.                if(fmax<d) {fmax=d;pmax=p;}///calculez fact max si puterea
  22.                else if(fmax==d)pmax+=p;
  23.             }
  24.             if(d*d<x)d++;
  25.             else d=x;
  26.         }
  27.     }
  28.     cout<<fmax<<" "<<pmax;
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement