题目链接:https://www.tyvj.cn/Problem_Show.aspx?id=1022
1 #include <cstdio> 2 #include <cstdlib> 3 #include <cmath> 4 long long int n, k, r; int a[100]; 5 int main(void) { 6 scanf("%lld",&n); int j=0; if(!n){printf("0\n");return 0;} 7 while(n) {k=n/(-2); r=n-(-2)*k; if(r==-1) n=k+1,r=1; else n=k; a[j++]=r; } 8 for(int k=j-1;k>=0;--k)printf("%d",a[k]);printf("\n"); 9 return 0; 10 }
=_=