Advertisement
cupsamada

1608

Feb 28th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<fstream>
  4. #include<algorithm>
  5. using namespace std;
  6. ifstream fin("sortare_divizori.in");
  7. ofstream fout("sortare_divizori.out");
  8. int v[1005];
  9. int c[1005];
  10. int main()
  11. {
  12. int nrd=0, n, i, d=0,x,r;
  13. fin>>n;
  14. for(i=1; i<=n; i++)
  15. {
  16. fin>>v[i];
  17. x=v[i];
  18. r=sqrt(x);
  19. for(d=1; d<=r; d++)
  20. {
  21. if(x%d==0)
  22. {
  23. nrd++;
  24. }
  25. if(x%(x/d)==0)
  26. {
  27. nrd++;
  28. }
  29. }
  30. if(r*r==x)
  31. {
  32. nrd--;
  33. }
  34. c[i]=nrd;
  35. nrd=0;
  36. }
  37. //sort(c+1,c+n+1);
  38. for(i=1; i<=n; i++)
  39. {
  40. fout<<c[i]<<" ";
  41. }
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement