可用binary search. 但用binary search 时,最好两边的可能性一样多。所以可以从7 问起。如下: (最多用5步,谁有空算算期望步数吧。) >= 7 ? Yes[cover 24 cards]--->=8? Yes[cover 17 cards]--->8? Yes[cover 9 cards]---(9) No[cover 8 cards]---->(8) No[cover 7 cards]----(7) No[cover 21 cards]---->=5? Yes[cover 11 cards]--->5? Yes[cover 6 cards]---(6) No[cover 5 cards]----(5) No[cover 10 cards]---->3? Yes[cover 4 cards]---(4) No[cover 6 cards]---->2? Yes[cover 3 cards]---(3) No[cover 3 cards]---->1? Yes[cover 2 cards]---(2) No[cover 1 card]-----(1) |
欢迎光临 珍珠湾ART (http://zzwav.com/) | Powered by Discuz! X3 |