freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-165-intersections.md

41 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
id: 5900f4111000cf542c50ff24
title: 问题165交叉口
challengeType: 5
videoUrl: ''
dashedName: problem-165-intersections
---
# --description--
段由其两个端点唯一定义。通过考虑平面几何中的两个线段存在三种可能性段具有零点一个点或无限多个共同点。此外当两个段恰好具有一个共同点时可能是该公共点是任一段或两者的端点的情况。如果两个段的公共点不是任一段的端点则它是两个段的内点。如果T是L1和L2的唯一公共点则我们将两个段L1和L2的公共点T称为L1和L2的真实交点并且T是两个段的内点。
考虑三个段L1L2和L3L127,4412,32L246,5317,62L346,7022,40可以证实线段L2和L3具有真实的交叉点。我们注意到作为L3的终点之一22,40位于L1上这不被认为是真正的交点。 L1和L2没有共同点。因此在三个线段中我们找到一个真正的交叉点。现在让我们对5000个线段进行相同的操作。为此我们使用所谓的“Blum Blum Shub”伪随机数生成器生成20000个数字。 s0 = 290797 sn + 1 = sn×snmodulo 50515093tn = snmodulo 500为了创建每个线段我们使用四个连续的数字tn。也就是说第一个线段由下式给出t1t2t3t4根据上述发生器计算的前四个数字应该是27,144,12和232.因此第一个线段是( 27,14412,232。在5000个线段中发现了多少个不同的真实交叉点
# --hints--
`euler165()`应该返回2868868。
```js
assert.strictEqual(euler165(), 2868868);
```
# --seed--
## --seed-contents--
```js
function euler165() {
return true;
}
euler165();
```
# --solutions--
```js
// solution required
```