Advertisement
Guest User

magic3

a guest
Apr 25th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. ifstream fin("magic3.in");
  6. ofstream fout("magic3.out");
  7.  
  8. int nrdiv(int n)
  9. {
  10.     int k;
  11.     if(n==1)        return 1;
  12.     k=2;
  13.     for(int d=2;d*d<=n;d++){
  14.         if(n%d==0){
  15.             k=k+2;
  16.         }
  17.         if(d*d==n){
  18.             k--;
  19.         }
  20.     }
  21.     return k;
  22. }
  23. int main()
  24. {
  25.     int n,a[1001],nrmindiv=1e9,x,S=0;
  26.     fin>>n;
  27.     for(int i=1;i<=n;i++){
  28.         fin>>a[i];
  29.         x=nrdiv(a[i]);
  30.         if(x<nrmindiv){
  31.                 S=1;
  32.                 nrmindiv=x;
  33.         }
  34.         else if (x==nrmindiv)    S++;
  35.     }
  36.     fout<<S;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement