Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. using namespace std;
  4. ifstream in("input.txt");
  5. ofstream out("output.txt");
  6. int main()
  7. {
  8. int A,B,contC=0,contP=0,contF=0,contR=0;
  9. in>>A;
  10. in>>B;
  11. int inizio=A,fine=B;
  12. for(int i=inizio;i<=fine;i++)
  13. {
  14. contC=0;
  15. contP=0;
  16. while(A!=1)
  17. {
  18. if(A%2==0)
  19. {
  20. A/=2;
  21. contC++;
  22. }
  23. else
  24. {
  25. A*=3;
  26. A++;
  27. contC++;
  28. }
  29. }
  30. A=i;
  31. while(A!=1)
  32. {
  33. if(A%2==0)
  34. {
  35. A/=2;
  36. contP++;
  37. }
  38. else if(contP>=contC+1)
  39. {
  40. A=1;
  41. }
  42. else
  43. {
  44. A*=5;
  45. A++;
  46. contP++;
  47. }
  48. }
  49. A=i;
  50. if(contP<contC)
  51. contR++;
  52. }
  53. out<<contR;
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement