3 solutions

  • 3
    @ 2024-8-13 16:13:48
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int x;
        cin>>x;
        if(x<0)
        {
            x=-x;
            cout<<1;
            for(int i=30;i>=0;i--)
            {
                if(x>>i&1)
                {
                    cout<<0;
                }
                else
                {
                    cout<<1;
                }
            }
        }
        else
        {
            cout<<0;
            for(int i=30;i>=0;i--)
            {
                if(x>>i&1)
                {
                    cout<<1;
                }
                else
                {
                    cout<<0;
                }
            }
        }
         
        return 0;
    }
    
    • 0
      @ 2026-1-3 10:46:06
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int x;
      	cin>>x;
      	if(x<0)
      	{
      		x=-x;
      		cout<<1;
      		bitset<32> a(x);
      		for(int i=30;i>=0;i--)
      		{
      			cout<<!a[i];
      		}
      	}
      	else
      	{
      		cout<<0;
      		bitset<32> a(x);
      		for(int i=30;i>=0;i--)
      		{
      			cout<<a[i];
      		}
      	}
      	return 0;
      }
      
      
      • -1
        @ 2024-11-3 10:12:47
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int x;
            cin>>x;
            if(x<0)
            {
                x=-x;
                cout<<1;
                for(int i=30;i>=0;i--)
                {
                    if(x>>i&1)
                    {
                        cout<<0;
                    }
                    else
                    {
                        cout<<1;
                    }
                }
            }
            else
            {
                cout<<0;
                for(int i=30;i>=0;i--)
                {
                    if(x>>i&1)
                    {
                        cout<<1;
                    }
                    else
                    {
                        cout<<0;
                    }
                }
            }
             
            return 0;
        }
        
        
        • 1

        Information

        ID
        129
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        1
        Tags
        (None)
        # Submissions
        50
        Accepted
        20
        Uploaded By