Advertisement
erfanul007

UVa 10940

Jun 8th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5.  
  6. #define read() freopen("input.txt", "r", stdin)
  7. #define write() freopen("output.txt", "w", stdout)
  8.  
  9. void fastIO()
  10. {
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(NULL);
  13. }
  14.  
  15. int main()
  16. {
  17. //read();
  18. //write();
  19. fastIO();
  20. int n,x;
  21. while(cin>>n && n){
  22. x=1;
  23. while(x*2<=n) x*=2;
  24. if(x!=n){
  25. n-=x;
  26. n*=2;
  27. }
  28. cout<<n<<'\n';
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement