Advertisement
a53

magic3

a53
Apr 9th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. int F[1000];
  4.  
  5. int NrDiv(int x) /// Calculez numarul nrd de divizori ai lui x
  6. {
  7. int nrd=1,k=x,p=0;
  8. while(!(k&1))
  9. ++p,k>>=1;
  10. nrd*=p+1;
  11. for(int d=3;d*d<=k;d+=2)
  12. {
  13. p=0;
  14. while(k%d==0)
  15. ++p,k/=d;
  16. nrd*=p+1;
  17. }
  18. if(k>1)
  19. nrd*=2;
  20. return nrd;
  21. }
  22.  
  23. int main()
  24. {
  25. int n;
  26. ifstream f("magic3.in");
  27. f>>n;
  28. int x;
  29. for(int i=0;i<n;++i)
  30. f>>x,F[i]=NrDiv(x);
  31. f.close();
  32. int MIN=1000000000;
  33. for(int i=0;i<n;++i)
  34. if(F[i]<MIN)
  35. MIN=F[i];
  36. int rez=0;
  37. for(int i=0;i<n;++i)
  38. if(F[i]==MIN)
  39. ++rez;
  40. ofstream g("magic3.out");
  41. g<<rez;
  42. g.close();
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement