GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Algorithm/leetcode_solved/leetcode_0069_Sqrt(x).cpp at master · OneCodeMonkey/Algorithm Expand file tree/ Copy pathleetcode_0069_Sqrt(x).cppMore file actions 20 lines (19 loc) · 459 Bytes / Copy pathleetcode_0069_Sqrt(x).cppFile metadata and controls20 lines (19 loc) · 459 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /** * AC: * Runtime: 4 ms, faster than 74.90% of C++ online submissions for Sqrt(x). * Memory Usage: 8 MB, less than 100.00% of C++ online submissions for Sqrt(x). * 思路:牛顿法,开方求平方根近似值的常用手法。 * */ class Solution { public: int mySqrt(int x) { if(x == 0) return 0; long raw = x; while(raw * raw > x) { raw = (raw + x / raw) / 2; } return raw; } }; |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |