2 solutions

  • 2
    @ 2024-8-24 15:56:21
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        int res;
        for(int i=30;i>=0;i--)
        {
        	if(n>>i&1)
        	{
        		res=1<<i;
    		}
    	}
    	cout<<res;
    	return 0;
    }
    
    • 1
      @ 2025-7-24 14:40:34
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n;
          cin>>n;
          int res;
          for(int i=30;i>=0;i--)
          {
          	if(n>>i&1)
          	{
          		res=1<<i;
      		}
      	}
      	cout<<res;
      	return 0;
      }
      
      
      • 1

      Information

      ID
      122
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      3
      Tags
      (None)
      # Submissions
      39
      Accepted
      20
      Uploaded By