1 solutions

  • 0
    @ 2025-5-31 15:43:04
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	int t=1;//当前需要拆成的数
    	while(t<=n) //还可以继续拆 
    	{
    		cout<<t<<" ";//输出当前的数
    		n-=t;//减去
    		t*=2; //得到下一个要拆的数 
    	} 
    	if(n) //剩余的是一个非0的数 
    	{
    		cout<<n;
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    51
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    119
    Accepted
    64
    Uploaded By