/* 自定義代碼塊樣式 */

herrDeng網內搜尋

自訂搜尋

Ads

2026年7月27日 星期一

0ms 速解Leetcode 1464 最大的乘積:別只會用 Sort!試試Py nlargest, C++ nth_element


0ms|1 line Py3 #nlargest #cpp #nth_element 速解 #Leetcode1464 最大的乘積
Python 1行解用heapq.nlargest。C++2行解用nth_element,都是linear 0ms
[C++, Py3 codes請進]

2026年7月8日 星期三

為什麼 0.1+0.2 != 0.3?IEEE 754 浮點數誤差原理與 Python/C++ 實測


The Math Error Every Programmer Must Know: IEEE 754
🌐 English audio available! Select "English" in the audio track settings (⚙️  Audio track) to listen in English.

電腦float計算含Python cpp示範0.1+0.2!=0.3
為什麼在 Python 或 C++ 中執行 0.1 + 0.2 == 0.3 會得到 False?這不是程式出錯,而是電腦底層採用 IEEE 754 二進位浮點數格式所導致的必然現象。
Related Posts Plugin for WordPress, Blogger...

熱門文章