Advertisement
a53

Catalin_si_greselile_EU

a53
Jan 14th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream f("greselile.in");
  4. ofstream g("greselile.out");
  5.  
  6. int nrdiv(int n)
  7. {
  8. int d,exp=0; // p retine numarul divizorilor
  9. if(n%2==0)
  10. {
  11. while(n%2==0)
  12. {
  13. exp++;
  14. n=n/2;
  15. }
  16. }
  17. d=3;
  18. while(n>1)
  19. {
  20. if(n%d==0)
  21. while(n%d==0)
  22. {
  23. exp++;
  24. n=n/d;
  25. }
  26. else
  27. d+=2;
  28. if(n>1&&d*d>n)
  29. {
  30. ++exp;
  31. break;
  32. }
  33. }
  34. return exp;
  35. }
  36.  
  37. int main()
  38. {
  39. int n,t,i;
  40. f>>n>>t;
  41. for(int k=0;k<t;++k)
  42. {
  43. f>>i;
  44. g<<nrdiv(i)<<'\n';
  45. }
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement