sabertooth09

Untitled

May 28th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. int main()
  6. {
  7.    unsigned ll t;
  8.    scanf("%I64d",&t);
  9.    while(t--)
  10.    {
  11.        unsigned ll i=0,n,x,m=999999999999999999;
  12.        scanf("%I64d",&n);
  13.        for(i=0;i<61;i++)
  14.        {
  15.           x=abs(n-pow(2,i));
  16.           m=min(m,x);
  17.        }
  18.        cout<<m<<endl;
  19.    }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment