推 jobsdone: Fenwick tree? 11/16 22:05
推 idiont: 第二種建立前綴和 n個人只要做n次加法 要從random的結果推 11/16 22:43
→ idiont: 出是誰也可以使用二分搜加速 不會很慢吧 11/16 22:43
→ bowin: 寫一個function隨機產生uniform(0,1),然後 11/17 03:35
→ bowin: 用probability integral transform抽出你要的元素 11/17 03:35
推 hare1039: 用 std::discrete_distribution 就直接可以解了 11/17 05:06
推 Schottky: 真士......是人狼君的作者? 11/17 05:49
→ Schottky: 幾萬個加法並不慢啊,抽獎池幾萬筆資料也不會很大 11/17 05:52
→ Schottky: 線性搜尋可以輕鬆處理的範圍,不到一秒吧 11/17 05:52
推 longlongint: 看需求 求效率的話上面回覆就夠用了 11/17 10:48
→ longlongint: 但是拿去抽轉蛋會被罵死 不如用 list 照比例配票 XD 11/17 10:48
→ longlongint: D 11/17 10:48
推 FRAXIS: 如果你是要同一個 distribution 重複抽的話 11/17 11:10
→ FRAXIS: 如果一個 distribution 只抽一次 那就 Reservoir Sampling 11/17 11:13
推 cutekid: 推 FRAXIS 大!學到好多。 11/17 14:04