bitget(repelem(0:numel(A)-1, A), 1)
[update] I modified my original but erroneous answer bitget(repelem(1:numel(A), A), 2). In his comments below, Andrei hit a serious flaw in this one. One does need to look at the last bit!
Thanks Andrei, for pointing this out.