sourabh_jangid's blog

By sourabh_jangid, history, 5 years ago, In English

I was solving 691E - Xor-последовательности, and in the problem asked to find number of ones in binary representation of a number, I was using C++ STL __builtin_popcount() function to find Number of ones, but when I submitted I got wrong answer verdict, and then I wrote my own function to count Number of ones and then my solution passed. Can anyone explain to me why this is happening? My AC 69283580 code and WA 69283537 code.

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it -6 Vote: I do not like it

int __builtin_popcount(unsigned int)

It returns the numbers of set bits in an integer (the number of ones in the binary representation of the integer). val is long long

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Use __builtin_popcountll(x) for long long ints.

69284505 : Accepted code with __builtin_popcountll(x) in place of __builtin_popcount(x)