the key of your 2nd step is actually because 2^n - 2^m <> 10 ^n (n>=2)!. in plain language: you can never mess 1 hat but get the same last 2 digits.
Now remember it actually also right 2^n - 2^m <> 1 . you can never mess up 1 hat but get the same last 1 digit!.
So, 第3步 ~~~
- you only need to know the last ONE digit and 會發現隻有 ONE arrangement可以由匯總得到的2進製數通過轉換1位數字得到... 99.1% now!
....
Now 第4步
...
...
...
...
note: let's say n= # of colors...
now if going through the long way and hard way (馬後炮 though), we do not need to trap ito the 2進製 <-> n進製 and you can eliminated the 進製transitions and exclusions.... Use n 進製 directly - that's the final simple and sweet answer posted earlier!
:)