Advertisement
FazEN

Untitled

Mar 17th, 2019
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include<iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. int a,b,c,count=0;
  9. cin>>a>>b>>c;
  10. int d=0;
  11. if (b-a>c-b) {
  12. d=b-a;
  13. }else {
  14. d=c-b;
  15. }
  16.  
  17. while (d!=1) {
  18. if (d%2==0) {
  19. d/=2;
  20. count++;
  21. }else {
  22. d=(d+1)/2;
  23. count++;
  24. }
  25. }
  26.  
  27. cout<<count;
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement