#include <stdio.h>
int ans[50];
int abs(int n)
{
return n < 0? -n: n;
}
int main()
{
int n, m, index, i, a;
scanf("%d", &n);
a = n;
while (n --)
{
scanf("%d", &m);
index = 0;
for (;m != 1 && m != 0;)
{
int add = 0;
if (m < 0 && m % 2) add = 1;
ans[index ++] = abs(m % -2);
m /= -2;
if (add) m ++;
if(m == -1) ans[index ++] = 1, m = 1;
}
if (m == 1) ans[index ++] = 1;
printf("Case #%d: ", a - n);
for (i = index - 1; i >= 0; i --)
printf("%d", ans[i]);
if (m == 0) printf("%d", 0);
printf("\n");
}
return 0;
}
回目錄
回首頁
沒有留言 :
張貼留言