| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
简单的递推?int main(){
int n;
cin>>n;
if(n==0) {
printf("0\n");
return 0;
}
int bit[50],cnt=0;
int sign = 1;
if(n<0) n=-n, sign = -1;
while(n){
int a = 0;
if(n&1){
bit[cnt++]=1;
if(sign<0) a = 1;
}else bit[cnt++]=0;
sign = -sign;
n/=2, n+=a;
}
for(int i=cnt-1;i>=0;i--) printf("%d",bit[i]);
printf("\n");
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator