It's a bizarre piece of code, I'm not sure entirely why it does what it does but it's easy enough to understand from a technical viewpoint (i.e., what it does).
The while
loop gets a series of characters from standard input and, for each unique one, adds one to the ans
variable. The expression !a[k]
will be true if a[k]
is zero (they're all initialised to this state).
When that condition is true, ans
is incremented and a[k]
is set to 1
, meaning any more characters of that value will not affect the outcome (the condition won't ever be true again).
In terms of the if
statement, the expression ans&1
will be true if ans
is odd (has its lower-order bit set).
So it appears it tells you to ignore people who have an odd number of unique characters in their names and talk to the others. Of course, the whole thing falls apart since you don't actually initialise ans
, meaning it can be an arbitrary value (not necessarily zero) and that this program is therefore pretty much able to tell you whatever it wants.
Once you've fixed that little issue, I'll be happy to chat further - paxdiablo
has eight unique characters. I should warn you in advance though, I'm not a "HER" :-)