Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- int F[1000];
- int NrDiv(int x) /// Calculez numarul nrd de divizori ai lui x
- {
- int nrd=1,k=x,p=0;
- while(!(k&1))
- ++p,k>>=1;
- nrd*=p+1;
- for(int d=3;d*d<=k;d+=2)
- {
- p=0;
- while(k%d==0)
- ++p,k/=d;
- nrd*=p+1;
- }
- if(k>1)
- nrd*=2;
- return nrd;
- }
- int main()
- {
- int n;
- ifstream f("magic3.in");
- f>>n;
- int x;
- for(int i=0;i<n;++i)
- f>>x,F[i]=NrDiv(x);
- f.close();
- int MIN=1000000000;
- for(int i=0;i<n;++i)
- if(F[i]<MIN)
- MIN=F[i];
- int rez=0;
- for(int i=0;i<n;++i)
- if(F[i]==MIN)
- ++rez;
- ofstream g("magic3.out");
- g<<rez;
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement