LeetCode Notes 026

Find Minimum in Rotated Sorted Array

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.

(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).

Find the minimum element.

You may assume no duplicate exists in the array.

阅读更多
ML-Lectures Perceptron

从感知机到简单神经网络

近年来,人工神经网络在深度学习的推动下获得了关注。什么是人造神经网络,它是由什么构成的?我想我们可能需要从感知器开始学起。

在这个讲座中,我们将严格推导感知机学习算法及其对偶理论,掌握一般的人工神经网络,并对单层甚至多层感知器进行编码实现。在几个实战例子中,我们采用人工神经元的最基本版本——感知器,来在超平面上对我们的数据集进行分类。

阅读更多
Project-Euler-029

Problem

Consider all integer combinations of $a^b$ for $2 \leq a \leq 5$ and $2 \leq b \leq 5$:

$$\begin{aligned}
& 2^2 = 4\text{, } 2^3 = 8\text{, } 2^4 = 16\text{, } 2^5 = 32 \
& 3^2 = 9\text{, } 3^3 = 27\text{, } 3^4 = 81\text{, } 3^5 = 243 \
& 4^2 = 16\text{, } 4^3 = 64\text{, } 4^4 = 256\text{, } 4^5 = 1024 \
& 5^2 = 25\text{, } 5^3 = 125\text{, } 5^4 = 625\text{, } 5^5 = 3125
\end{aligned}$$

If they are then placed in numerical order, with any repeats removed, we
get the following sequence of 15 distinct terms:

$$4\text{, } 8\text{, } 9\text{, } 16\text{, } 25\text{, } 27\text{, } 32\text{, } 64\text{, } 81\text{, } 125\text{, } 243\text{, } 256\text{, } 625\text{, } 1024\text{, } 3125$$

How many distinct terms are in the sequence generated by $a^b$ for
$2 \leq a \leq 100$ and $2 \leq b \leq 100$?

阅读更多
Project-Euler-028

Problem

Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:

21 22 23 24 25
20  7  8  9 10
19  6  1  2 11
18  5  4  3 12
17 16 15 14 13

It can be verified that the sum of the numbers on the diagonals is 101.

What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?

阅读更多
Project-Euler-027

Problem

Euler published the remarkable quadratic formula:

$$
n^2 + n + 41
$$

It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, $40^2 + 40 + 41 = 40(40 + 1) + 41$ is divisible by 41, and certainly when n = 41, $41^2 + 41 + 41$ is clearly divisible by 41.

Using computers, the incredible formula $n^2 - 79n + 1601$ was discovered, which produces 80 primes for the consecutive values n = 0 to 79. The product of the coefficients, 79 and 1601, is 126479.

Considering quadratics of the form:

$$
n^2 + an + b, \text{ where } |a| \lt 1000 \text{ and } |b| \lt 1000
$$

Find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of primes for consecutive values of n, starting with n = 0.

阅读更多
Project-Euler-026

Problem

A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:

$$
\begin{aligned}
\frac{1}{2}&=0.5 \\
\frac{1}{3}&=0.\overline{3} \\
\frac{1}{4}&=0.25 \\
\frac{1}{5}&=0.2 \\
\frac{1}{6}&=0.1\overline{6} \\
\frac{1}{7}&=0.\overline{142857} \\
\frac{1}{8}&=0.125 \\
\frac{1}{9}&=0.\overline{1} \\
\frac{1}{10}&=0.1
\end{aligned}
$$

Where $0.1\overline{6}$ means $0.1666…$, and has a 1-digit recurring cycle. It can be seen that $\frac{1}{7}$ has a 6-digit recurring cycle.

Find the value of $d < 1000$ for which $\frac{1}{d}$ contains the longest recurring cycle in its decimal fraction part.

阅读更多