"RBEES - Editorial"

PROBLEM CODE: RBEES
CONTEST CODE: CYPH2021
PROBLEM LINK : RBEES
Author: schnell_31
Tester: schnell_31

Editorialist: schnell_31

PREREQUISITES: Bit

EXPLANATION :
To solve this problem, write down x into its binary form. If the ith least significant bit is 1 and x contains n bits, we put one bees into this box in the morning of (n + 1 - i)th day. Then at the noon of the nth day, the box will contain x bees. So the answer is the number of ones in the binary form of x.

SOLUTION:

int main(){
           int n,an=0;
   	scanf("%d",&n);
   	while(n){
       		if(n&1)an++;
       		n>>=1;
   	}
   	printf("%d\n",an);
   	return 0;
}`

Contest was really Good like in sight of problems .