3 solutions

  • 1
    @ 2026-7-7 15:17:49
    #include <bits/stdc++.h> 
    using namespace std;
    int main()
    { 
      int x;
      cin>>x;
      bitset<32> a(x);
      int cnt=0;
      for(int i=31;i>=0;i--)
      {
        if(a[i]==1)
        {
          cnt++;
        }
      }
      cout<<cnt;
      return 0;
    }
    
    • 0
      @ 2026-7-7 15:17:55
      #include<bits/stdc++.h>
      using namespace std;
      int main(){	
      	int n;
      	cin>>n;
      	bitset<32> a(n);
      	cout<<a.count(); 
      	return 0;
      }
      
      • 0
        @ 2026-6-13 11:35:04

        #include <bits/stdc++.h> using namespace std;

        int main() { int x; cin>>x; bitset<32> a(x); int cnt=0; for(int i=31;i>=0;i--) { if(a[i]==1) { cnt++; } } cout<<cnt; return 0; }

        • 1

        Information

        ID
        123
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        1
        Tags
        (None)
        # Submissions
        71
        Accepted
        37
        Uploaded By