1 solutions

  • 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

    Information

    ID
    9122
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By