Advertisement
STANAANDREY

1/4/2019

Apr 1st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  unsigned n,i,v[1000],nr2=0,nr5=0,f,p,k;
  7.  cout<<"n=";cin>>n;
  8.  for (i=0;i<n;i++)
  9.  cin>>v[i];
  10.  
  11. for (i=0;i<n;i++)
  12. {
  13.     f=2;
  14.     while (v[i]>1)
  15.     { p=0;
  16.         while (v[i]%f==0)
  17.         {
  18.             v[i]/=f;
  19.             p++;
  20.         }
  21.         if (p)
  22.         {
  23.             if (f==2)
  24.                 nr2+=p;
  25.             else
  26.                 if (f==5)
  27.                 nr5+=p;
  28.         }
  29.         f++;
  30.     }
  31. }
  32. k=(nr2<nr5)?nr2:nr5;
  33.  cout<<"0 apare de "<<k<<" ori in prdusul elementelor";
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement