1 条题解

  • 0
    @ 2024-12-5 18:12:19

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int n;
    int power(int x){
    	int i=2;
    	while(i<=x) i*=2;
    	return i/2;
    }
    int main(){
    	cin>>n;
    	if(n%2==0){
    		while(n!=0){
    			cout<<power(n)<<" ";
    			n-=power(n);
    		}
    	}else{
    		cout<<"-1";
    	}
    	return 0;
    }
    
    • 1

    信息

    ID
    9122
    时间
    1000ms
    内存
    256MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者