2 solutions

  • 0
    @ 2026-1-3 9:42:59
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	bitset<32> a(n);
    	if(a[0]==1)
    	{
    		cout<<-1;
    	}
    	else
    	{
    		for(int i=31;i>=0;i--)
    		{
    			if(a[i]==1)
    			{
    				cout<<(1<<i)<<" ";
    			}
    		}
    	}
    	return 0;
    }
    
    
    • -1
      @ 2024-10-16 20:18:16
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      int n;
      cin>>n;
      if(n%2==1)
      {
      	cout<<-1;
      }
      else
      {
      	for(int i=30;i>=1;i--)
      	{
      		if(n>>i&1)
      		{
      			cout<<(1<<i)<<" ";
      		}
      	 } 
       } 
      return 0;
      }
      
      
      
      • 1

      Information

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