不要用pow.如本蒟蒻:
#include <iostream>
#include <cmath>
using namespace std;
long long n;
int main(){
cin >>n;
if(n%2==1){
cout <<-1 <<endl;
return 0;
}
while(n>0){
long long i=1;
while(pow(2,i)<=n){
i++;
}
cout <<pow(2,i-1) <<" ";
n-=pow(2,i-1);
}
return 0;
}
很好,80分。
然后找了半天都没有发现问题。
然后我看了样例17:
in:9999998
out:8388608 1048576 524288 32768 4096 1024 512 64 32 16 8 4 2
我的输出:8.38861e+006 1.04858e+006 524288 32768 4096 1024 512 64 32 16 8 4 2
然后自己打了个pow:
int pow_(int x,int y){
int ans=1;
for(int i=1;i<=y;i++){
ans*=x;
}
return ans;
}
就AC了。。。