在本地都能过,可为什么在洛谷上就只有30分呢?
代码:
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
stack<int>S;
int n;
int len;
int book=1;
int main(){
cin>>n;
if(n&1==1){
cout<<"-1";
return 0;
}
while(n){
if(n&1==1){
S.push(1);
}else{
S.push(0);
}
len++;
n>>=1;
}
for(int i=len-1;i>=0;i--){
if(S.top()==1){
cout<<book<<' ';
}
S.pop();
book<<=1;
}
return 0;
}