8 solutions

  • 0
    @ 2026-8-14 19:56:28
    #include<bits/stdc++.h>
    using namespace std;
    int n;
    int main()
    {
    	cin>>n;
    	int i;
    	for(i=1;i>0;i*=2){
    		if(i>n) break;
    	}
    	i/=2;
    	if(n%2!=0) {
    		cout<<-1;
    		return 0;
    	}
    	while(n>0){
    		if(n>=i){
    			n-=i;
    			cout<<i<<" ";
    		}
    		i/=2;
    	}
    	return 0;
    }
    

    Information

    ID
    125
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    98
    Accepted
    38
    Uploaded By