Advertisement
Saleh127

UVA 10940

Aug 20th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);cout.tie(0);
  7.  
  8. int n,a,c,d,e;
  9.  
  10. while(cin>>n && n)
  11. {
  12. a=1;
  13. while(a*2<=n)
  14. {
  15. a*=2;
  16. }
  17. if(a-n==0)
  18. {
  19. cout<<n<<endl;
  20. }
  21. else cout<<(n-a)*2<<endl;
  22. }
  23. return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement