CSAPP Data Lab
2020-07-02
Data Lab 的题1,第一眼觉得不难,仔细一看发现限制非常严格,比如只允许部分位运算符等,难度一下子就上去了,所以花了不少时间。 dlc 是 64 位 Linux 程序,使用 ./dlc…
素数筛法和哥德巴赫猜想
2019-01-03
起因是看到了这个帖子如果高中生能证明哥德巴赫猜想,会被清华北大数学系保送吗? - 知乎 ,emmm… 本文的目标是筛选 32 位无符号整数(…
幂运算 pow(x, n) 的一个迭代实现
2018-08-24
求一个浮点数的整数次幂: https://leetcode.com/problems/powx-n/ Implement pow(x, n), which calculates x raised to the power n (i.e. xn). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: Input: x = 2.00000, n = -2 Output: 0.25000 Explanation: 2-2 = 1/22 = 1/4 = 0.25 Constraints: -100.0…
Single Number II
2017-11-27
LeetCode 的一道题,在一个 int 数组中,其余数值均出现了 3 次,只有一个数值出现了 1 次,求这个数: https://leetcode.com/problems/single-number-ii/description/ Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a…