mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
808996d897
5100-5199
18 lines
399 B
C++
18 lines
399 B
C++
#include<cstring>
|
|
#include<cstdio>
|
|
#include<cmath>
|
|
int buf[40];
|
|
void go(int n) {
|
|
int i, j = 0, res = 0;
|
|
memset(buf, 0, sizeof(buf));
|
|
do buf[j++] = n % 2; while (n /= 2);
|
|
for (i = j - 1; ~i; i--) res += buf[i] * (int)pow(2, j - i - 1);
|
|
printf("%d\n", res);
|
|
}
|
|
int main() {
|
|
int t, n;
|
|
scanf("%d", &t);
|
|
while (t--) scanf("%d", &n), go(n);
|
|
return 0;
|
|
}
|