herrDeng網內搜尋
自訂搜尋
Ads
2026年7月16日 星期四
2026年7月13日 星期一
2026年7月11日 星期六
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 二進位浮點數格式所導致的必然現象。
2026年7月7日 星期二
2026年7月5日 星期日
2026年7月2日 星期四
LeetCode 3286: 別只用 Dijkstra!0-1 BFS (deque) 才是 0ms 關鍵
0ms |C++ Py3| BFS使用deque解Leetcode 3286 Find a Safe Walk Through a Grid
了解以下幾點有助於解決最短路徑問題:
所有權重相同時,只需使用基於佇列queue的廣度優先搜尋(BFS over queue)
權重有兩種非負值(如本題所示),使用基於雙端佇列(deque)的廣度優先搜尋(BFS over deque)
權重為正值時,使用基於優先權佇列(priority queue)的廣度優先搜尋(類似Dijkstra演算法)
2026年7月1日 星期三
Beats 100%|C++ UnionFind BFS解Leetcode 2812 Find the Safest Path in a Grid
Beats 100%|C++ unionFind BFS linkedList解Leetcode 2812 Find the Safest Path in a Grid
本影片詳細講解如何結合 UnionFind與 BFS(廣度優先搜尋)來解決 LeetCode 2812. Find the Safest Path in a Grid。透過 BFS 預處理所有格子到最近小偷的距離,再利用 UnionFind 找出具有最大安全性係數的路徑,最終在 C++ 實作中達到 182ms 並擊敗 100% 的紀錄!
2026年6月30日 星期二
2026年6月27日 星期六
C++ bitset array依數字 3、13、177、31622分割解Leetcode 3020 Find the Maximum Number of Elements in Subset
C++ bitset array依數字 3、13、177、31622分割解Leetcode 3020 Find the Maximum Number of Elements in Subset
不用hashmap,另圖蹊徑才有辦法快速解答Leetcode 3020.
-----
No Hashmap—forging a new path to crush LeetCode 3020 fast.
Trick: isqrt(1e9)=31622 , 177, 13, 3
[codes on Leetcodes]https://leetcode.com/problems/find-the-maximum-number-of-elements-in-subset/solutions/8360422/divide-nums-according-to-3-1317731622bea-5tk4/
#anwendeng
訂閱:
文章 (Atom)
熱門文章
-
明文=I'm student key=(2,15,8) 密文=?
-
C字串練習 字串 char word[]="You win!"; 輸出為: You win! You win You wi You w You You Yo Y 給進階使用者: gets () 是個危險的函式!
-
請用C/C++ 程式計算 S=1*1+2*2+3*3+4*4+.....+20*20=?
-
GCD(123456789,345634567)=?
-
計算你的BMI
-
array ex 1, 2,3,7,8
-
列印課表數字代碼矩陣,以及代碼的課名 提示: 參考此連結
-
統計第一作業 2, 3, 8, 9