PRIMEBIT - Editorial

PRIMEBIT EDITORIAL.
Problem Link:- PRIMEBIT

SETTER : @arpitgupta16
Editorialist : @arpitgupta16

Difficulty : Easy

Pre-Requisites : binary number system, bitwise operator.

EXPLANATION : Here we had to find sum of positions of set bits in the given number. For this we will check each bit of number and if the bit is set-bit we will add the position of that bit in the answer. Finally print the answer.
e.g. 19 == 10011.
output = 4+1+0 = 5.

Setter’s and Editorialist’s Solution:

Setters and Editorialists Solutions.

Solution Link.

Hope you liked it and feel free to share any approach or ask any doubts in comments below. Other optimal solutions are encouraged too.

What is wrong with my my code? after execute this in my IDE the program worked properly and give the expected output. but after submitting this I got NZEC error. why?
here is my submission link: CodeChef: Practical coding for everyone

if t>=1 and t<=1000:
T = t
for _ in range(T)

Why did you do this ? Given constraints say T>1000

2 Likes

Yes, it was the mistake. I write 1000 at the place of 1000000.