Advertisement
alex326

Untitled

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