全部评论 2

  • #include<bits/stdc++.h>
    using namespace std;
    int n;
    int main(){
    	cin>>n;
    	if(n&1){
    		cout<<-1;
    	}
    	else{
    		for(int i=23;i>=1;i--){
    			if((n>>i)&1){
    				cout<<(1<<i)<<" ";
    			}
    		}
    	}
    }
    

    3天前 来自 重庆

    1
  • 没我好

    #include <bits/stdc++.h>
    
    using namespace std;
    
    long long n;
    
    int main( ) {
    	cin >> n;
    	
    	if (n % 2 == 1) {
    		cout << "-1" << endl;
    		return 0;
    	}
    	long long x = log2(n);
    	
    	for (int i = x ; i >= 1 ; i--) {
    		if ((1 << i) <= n) {
    			cout << (1 << i) << " ";
    			n -= (1 << i);
    		}
    	}
    	
    	return 0;
    })
    

    2025-09-12 来自 福建

    0
暂无数据

提交答案之后,这里将显示提交结果~

首页